Q. Which format specifier is used to read and print the string using printf() and scanf() in C?
β
Correct Answer: (D)
%s
Explanation: The format specifier "%s" is used to read and print the string using printf() and scanf() in C.
Example:
#include <stdio.h>
int main()
{
char name[30];
printf("Input name: ");
scanf("%s", name);
printf("Given name is: %s", name);
return 0;
}
/*
Output:
Input name: Alvin
Given name is: Alvin
*/