In this tutorial you will learn about the C Program to accept User Input and Print and its application with practical example.
C Program to accept User Input and Print
In this tutorial, we will learn to create a C program that will accept User Input and Print in C programming.
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C Programming.
What is an integer?
The integer is a positive or negative whole number including zero. These are the number real numbers.
Algorithm to print:-
1. Declaring the variables for the program.
2. Taking the input from the user in integer and character format.
3. Printing the data taken in input from the user in number and character format.
4. End the program.
Program to Print Integer
As we all know the integer, character, float, or double value in c programming. In c programming, we can take the input from the user in character & number format. In this program, we will take input in integer format. The second will display the integer & character with the help of a small program. The integer & character are the most useful terminology in any programing language. For number/arithmetic manipulation in c programming, there are many predefined functions available.
With the help of this program, we can accept User Input and Print.
/* C Program to accept User Input and Print */
//declaring the required variables for the program.
//num = it will hold the number value
//ch = it will hold the character value
/* Taking the Input character from user */
printf("\nPlease enter any Character = ");
//Scanning the character input
printf("The User Enetered Charcater = %c\n", ch);
/* Taking the Input number from user */
printf("\nPlease enter any number = ");
//Scanning the number input
//Printing the Enetered Float Value to the user.
printf("The User Enetered Float Value = %.2f\n", num);
return 0;// return 0 to operating system
In the above program, we have first initialized the required variable.
- num = it will hold the input number value from the user.
- ch = it will hold the character number value from the user.
Taking Input character from the user.
Taking the number value.
Printing the number value.