Home / Programs / Write a program that demonstrates the use of %s conversion specifier in scanf( ).
Programming Example

Write a program that demonstrates the use of %s conversion specifier in scanf( ).

👁 844 Views
💻 Practical Program
📘 Step by Step Learning
Write a program that demonstrates the use of %s conversion specifier in scanf( ).

Program Code

#include <stdio.h>

int main()
{
  char str[50];

  printf("Enter a string ");
  scanf("%s",str);

  printf("The string was :%s\n",str);

  return 0;

 }

Output

Enter a string  atnyla
The string was :atnyla

Explanation

None

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.