16. Place Holder Data Type Displayed
%i , %d int, long, short, char,
unsigned int
Decimal Value, ASCII
value
%u Unsigned int Decimal Value
%o Int Octal Value
%x, %X Int Hexadecimal
%f Float Float value with zeros
%g %G Float, Double Float value with no zeros
%e, %E Float, Double Float in exponent
%lf Double Double value
%c Char Single character
%s Array of Character String
17. #include<stdio.h>
void main(){
printf("Decimal No =%5d",123);
printf("nOctal No =%5o",123);
printf("nHex No =%5x",123);
printf("nFloat with g =%5g",123.456);
printf("nFloat with f =%5f",123.4560);
printf("nFloat with f =%5.1f",123.4560);
printf("nFloat with lf =%5lf",123.456);
printf("nFloat with e =%5e",123.456);
printf("nSingle Char = %5c",'A');
printf("nString %5s","Hello");
}
printf
Decimal No = 123
Octal No = 173
Hex No = 7b
Float with g =123.456
Float with f =123.456000
Float with f =123.5
Float with lf =123.456000
Float with e =1.234560e+002
Single Char = A
String Hello
18. #include<stdio.h>
void main(){
int a=45;
int *ptr=&a;
unsigned int b=56;
printf("Address of a in decimal =%dn",&a);
printf("Address of a in hexadecimal =%xn",&a);
printf("Content of pointer =%p",ptr);
printf("Decimal No =%d",b);
}
Address of Variable
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29. • Single character
• #include<stdio.h>
• void main(){
• char ch;
• ch=getchar();
• putchar(ch);
• }
getchar(), putchar()
30. • When we use %s for scanf,
it only scans string before
white space
• White spcace can be space,
tab or new line
scanf() for string
#include<stdio.h>
void main(){
char sen[50];
scanf(“%s”,sen);
printf(sen);
}
32. getc() and putc()
#include<stdio.h>
void main(){
char ch;
ch=getc(stdin);
putc(ch,stdout);
}
• Reads single
character from
specified source
• Write single
character to specified
resource