Read & Write Value from User in C Language

  • In this program first we declared a variable having name No, Then, the user is asked to enter any integer number. This number is stored in our declared variable No.
  • Finally, the value stored in variable is displayed on the console/screen using printf() library function.
#include <stdio.h>
int main() 
{   
    int No;
   
    printf("Enter any integer value: ");  
    
    // Reads and stores data
    scanf("%d", &No);

    // displays output on console
    printf("You have entered: %d", No);
    
    return 0;
}

Output :

Enter any integer value: 5
You have entered: 5

Add a Comment

Add a Comment