Posted on Leave a comment

‘C’ Program to get input from a user using scanf command

Example: ‘C’ Program to get input from a user using scanf command

  1. #include <stdio.h>
  2. int main()
  3. {
  4.   int x;
  5.   printf(“Input an integer\n”);
  6.   scanf(“%d”, &x); // %d is used for an integer
  7.   printf(“The integer is: %d\n”, x);
  8.   return 0;
  9. }

Output:
Input an integer
7897
The integer is: 7897

Leave a Reply

Your email address will not be published. Required fields are marked *