Thursday, March 26, 2020

c program to display an integer value

C Program to print Integer value

#include 
int main() 
{   
    int number;
   
    printf("Enter an integer: "); //user value 
    
    // reads and stores input
    scanf("%d", &number);

    // displays user output
    printf("You entered: %d", number);
    
    return 0;
}

Output

Enter integer number = 45
You entered 45

How program works ?

  • In this program, an integer variable number is declared.
Int number;
  • Then. the user asked to enter an integer number, This number is stored in the number  variable.
printf("Enter an integer: ");
scanf("%d", &number);
  • Finally, the value stored in number is displayed on the screen using printf().
printf("You entered: %d ",number );

0 comments:

Post a Comment

Recent Posts