In this tutorial you will learn about the C Program to Print an Integer, Character, and Float Value and its application with practical example.
In this tutorial, we will learn to create a C program that will Print an Integer, Character, and Float Value using C programming.
Prerequisites
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.
- Arithmetic operations in C Programming.
What is a data type?
A data type, in every programming language, specifies which type of value a variable is going to hold in the program. i.e. integer, character, float, double.
Algorithm for the program to Print an Integer, Character, and Float Value:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
1. Initiating the program 2. Declaring the variables for the prorgam 3. Taking the input from the user in character data type format. 4. Taking the input from the user in integer data type format. 5. Taking the input from the user in float data type format. 6. Taking the input from the user in double data type format. 7. Printing the values one by one. 8. End the prorgam. |
Program Print an Integer, Character, and Float Value.
In every programming language, there are many predefined datatypes available. Today we will create a program that will print the integer, character, float, and double in output. By taking input values from the user.
With the help of this program, we can Print an Integer, Character, and Float Value.
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
/* C program to Print Integer, Char, Float and Double value */ #include <stdio.h> int main() { //Declaring the required variables for the program. int intg; char ch; float flt; double dub; //Taking the input values from the user in character printf(" Please Enter a Character : "); scanf("%c", &ch); //Taking the input values from the user in integer printf(" Please Enter an Integer Value : "); scanf("%d", &intg); //Taking the input values from the user in float printf(" Please Enter Float Value : "); scanf("%f", &flt); //Taking the input values from the user in double printf(" Please Enter Double Value : "); scanf("%lf", &dub); //Printing the output values to the user. printf(" \n The Integer Value that you Entered is : %d", intg); printf(" \n The Character that you Entered is : %c", ch); printf(" \n The Float Value that you Entered is : %2f", flt); printf(" \n The Double Value that you Entered is : %f", dub); return 0; } |
Output:-
Taking Input values from the user.
Printing the values.