πŸ“Š C Programming
Q. Which format specifier is used to read and print the string using printf() and scanf() in C?
  • (A) %c
  • (B) %str
  • (C) %p
  • (D) %s
πŸ’¬ Discuss
βœ… 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
*/

Explanation by: Chandani
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
*/

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
315
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Chandani
Publisher
πŸ“ˆ
91%
Success Rate