In this tutorial, we will discuss a simple concept of Write a C program to print an integer – entered by user
In this post, we are going to learn about how to print a integer number entered by user in C programming language
The value is stored in a variable num using scanf() function and it is displayed on the screen usint printf() function
Program 1
Program 1
#include <stdio.h> #include <stdlib.h> int main() { int num; //variable declaration printf("Enter an integer: \n"); //printf() displays the formatted output scanf("%d",&num); //scanf() reads the formatted input printf("you entered %d",num); getch(); return 0; }
When the above code is executed, it produces the following results
Enter an integer 56 you entered 56
In the C program, the user can enter a value using scanf() function and the value stored in a variable named as num. then, the value prints using printf() function.
In this program, printf() function provides a piece of information to the user to entering an integer value
printf("Enter an integer: \n");
The scanf() function reads an integer data from the user and stores in variable num
scanf("%d",&num);
Finally, the value stored in the variable num is displayed on the screen by using printf() function
printf("you entered %d",num);
Recommended post
Write a Java program to print an integer
Write a Cpp program to print an integer
Write a Python program to print an integer
Suggested for you
PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…
PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…
5 methods to add two numbers in Java In this tutorial, we will discuss the…
Python full Pyramid star pattern program In this tutorial, we will discuss the concept of…
Write a function or method to convert C into F -Entered by the user In…
How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…