Search Your Topic

config
Friday, 19 May 2017 04:07

C Program to Print an Integer

Written by
Rate this item
(0 votes)

In this program, integer entered by the user is stored in a variable. Then, that variable is displayed on the screen using printf() function.

Program to Print an Integer

#include <stdio.h>
int main()
{
    int number;

    // printf() dislpays the formatted output 
    printf("Enter an integer: ");  
    
    // scanf() reads the formatted input and stores them
    scanf("%d", &number);  
    
    // printf() displays the formatted output
    printf("You entered: %d", number);
    return 0;
}

Output

Enter a integer: 25
You entered: 25

In this program, an integer variable number is declared.

The printf() function displays Enter an integer: on the screen. Then, the scanf()function reads an integer data from the user and stores in variable number.

Finally, the value stored in the variable number is displayed on the screen using printf()function.

Read 473 times Last modified on Friday, 19 May 2017 04:10
Anish Sir

"I am delighted once again to pen the welcome note to the Tosh!Yas Technologies ."

 Call +91 74 88 34 7779  | Email : anishsingh@live.com

toshiyas.in

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.