How to write a C program to Print Integer, Char, and Float value with an example. It will showcase the use of format specifiers in C programming
C program to Print Integer, Char, and Float value
This C program lets the user enter One integer value, character, and a float value. And then we use the printf statement to print them out.
/* C program to Print Integer, Char, and Float value */
#include <stdio.h>
int main()
{
int Integer;
char Character;
float InputFloat;
printf(" Please Enter a Character : ");
scanf("%c", &Character);
printf(" Please Enter an Integer Value : ");
scanf("%d", &Integer);
printf(" Please Enter Float Value : ");
scanf("%f", &InputFloat);
printf(" \n The Integer Value that you Entered is : %d", Integer);
printf(" \n The Character that you Entered is : %c", Character);
printf(" \n The Float Value that you Entered is : %f", InputFloat);
printf(" \n The Float Value with precision 2 is : %.2f", InputFloat);
return 0;
}

Within this program to Print Integer, Char, and Float value example; first, we declared three variable of type Integer, Character, and Float. Below statements will ask the user to enter one character, an integer value, and a floating-point value.
printf(" Please Enter a Character : ");
scanf("%c", &Character);
printf(" Please Enter an Integer Value : ");
scanf("%d", &Integer);
printf(" Please Enter Float Value : ");
scanf("%f", &InputFloat);
Or, you can simply write the below statement instead of the above statement.
printf(" Please Enter a Character, Integer, and Float Value : ");
scanf("%c %d %f", &Character, &Integer, &InputFloat);
Lastly, we use the C Programming printf statement to print those user entered values as output.
Comments are closed.