To print formatted output by using printf function C provide us different type specifiers
Type specifier | Meaning | Datatype |
---|---|---|
%d %i | decimal integer | int |
%o | octalinteger | int |
%x | Hexadecimal integer | int |
%c | Character | char |
%f | floating-point number | float |
%lf | floating-point number | double |
%e | Double floating-point number | float and double |
%c | Character | char |
%s | String | char |
%hd | short integer | short int |
%ld %li | long integer | long int |
%u | unsigned integer | unsigned int |
%hu | unsigned short integer | unsigned short int |
%lu | unsigned long integer | unsigned long int |
%llu | unsigned long long integer | unsigned long long int |
%lf | long double | long double |
%p | Memory address in the hexadecimal | pointer |
#include<stdio.h> main() { int a=12; float b=14.45; char c='R'; short int d=12; unsigned long int e=100000; printf("a=%d %o %x \n",a,a,a); printf("b=%f \n",b); printf("c=%c \n",c); printf("d=%hd \n",d); printf("e=%lu \n",e); }
a=12 14 c b=14.450000 c=R d=12 e=100000