In C programming to print the value of integer or float we use printf(); function with format specifiers %d and %f
for integer and float respectively. Format specifier using in between the double-cot. like "%d". There are many other format specifier to print different data-type as follows.
char - %c
double - %lf
long int - %ld
string - %s
Syntax:
printf("%d",<variable name>); // For integer value.
printf("%f",<variable name>); // For float value.
char - %c
double - %lf
long int - %ld
string - %s
Syntax:
printf("%d",<variable name>); // For integer value.
printf("%f",<variable name>); // For float value.
Source Code To display integer and float.
#include<stdio.h>
void main()
{
int no1;
float no2;
no1=12;
no2=24.56;
clrscr();
printf("%d",no1); //to print integer value
printf("\n"); // \n is for the new line.
printf("%f",no2); // to print float value.
getch();
}
Download |
---|
0 comments:
Post a Comment