A

Admin • 833K Points
Coach

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
  • Correct Answer - Option(D)
  • Views: 27
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

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
*/

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.