Monday, February 17, 2020

C program to get input from a user using scanf


#include <stdio.h>
int main()
{
  int x;
  printf("Input an integer\n");
  scanf("%d", &x); // %d is used for an integer
  printf("The integer is: %d\n", x);
  return 0;
}


Output:

Input an integer
7897
The integer is: 7897

No comments:

Post a Comment