C

Chandani • 9.82K Points
Tutor III

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

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

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics