Home / Programs / Write a program that demonstrates the use of scanset in scanf().
Programming Example

Write a program that demonstrates the use of scanset in scanf().

👁 28,008 Views
💻 Practical Program
📘 Step by Step Learning
Write a program that demonstrates the use of scanset in scanf().

Program Code

// Write a program that demonstrates the use of scanset in scanf().

#include<stdio.h>

int main()
{
  char str[50];
  
  printf("Enter a string in lower case:");
  scanf("%[a-z]",str);
  
  printf("The string was : %s\n",str);
  
  return 0;
 }

Output

Enter a string in lower case: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.