Printf questions and answers in c programming language
1.
What will be output of the
following c code?
#include <stdio.h>
int main(){
int a=5,b=6,c=11;
printf( "%d %d
%d" );
return 0;
}
2.
What will be output of the
following c code?
#include <stdio.h>
int main(){
char *str= "CQUESTIONBANK" ;
printf(str+9);
return 0;
}
3.
What will be output of the
following c code?
#include <stdio.h>
int main(){
printf( "%d" ,printf( "CQUESTIONBANK" ));
return 0;
}
Explanation:
Printf function returns and
integer type data which is equal to the number of characters it prints.
4.
What will be output of the
following c code?
#include <stdio.h>
int main(){
short int a=5;
printf( "%d" +1,a);
return 0;
}
5.
What will be output of the
following c code?
#include <stdio.h>
int main(){
int i=85;
printf( "%p
%Fp" ,i,i);
return 0;
}
6.
What will be output of the
following c code?
#include <stdio.h>
int main(){
char p[]= "ok%s%c%s" ;
int a=8;
printf(p+2, "mone" ,a, "key" );
return 0;
}
7.
What will be output of the
following c code?
#include <stdio.h>
int main(){
int a=13;
printf( "india%cpak" ,a);
return 0;
}
8.
What will be output of the
following c code?
#include <stdio.h>
int main(){
char name1[]= "sachin" ;
char name2[]= "al" ;
printf( "%s\b\b\b%s" ,name1,name2);
return 0;
}
9.
What will be output of the
following c code?
#include <stdio.h>
int main(){
char name1[]= "qwertyudgbank" ;
char name2[]= "cquestion" ;
printf( "%s\r%s" ,name1,name2);
return 0;
}
10.
What will be output of the
following c code?
#include <stdio.h>
int main(){
static int x;
printf( "%d %d
%d" ,++x,x++,x++);
return 0;
}
11.
What will be output of the
following c code?
#include <stdio.h>
int main(){
printf( "%d" ,printf( "one" ));
return 0;
}
12.
What will be output of the following
c code?
#include <stdio.h>
int main(){
char *str= "cquestionbank.blogspot.com" ;
printf( "%*.*s" ,8,5,str);
return 0;
}
13.
What will be output of the
following c code?
#include <stdio.h>
int main(){
char *str= "cquestionbank.blogspot.com" ;
printf( "%*.*s" ,8,5,str);
return 0;
}
14.
What will be output of the
following c code?
#include <stdio.h>
extern int a;
static int a;
int main(){
printf( "%d+%i" ,a,a);
return 0;
}
int a=10;
15.
What will be output of the
following c code?
#include <stdio.h>
int main(){
printf( "\\\\" );
return 0;
}
16.
What will be output of the following
c code?
#include <stdio.h>
int main(){
int num= 054;
printf( "%x
%X" ,num,num);
return 0;
}
17.
What will be output of the
following c code?
#include <stdio.h>
int main(){
int num= 0x21;
printf(1+ "%s
%#o" , '=' ,num);
return 0;
}
18.
What will be output of the
following c code?
#include <stdio.h>
int main(){
float f= 0x21E02F;
char *str= "%.2f" ;
printf(str,f);
return 0;
}
19.
What will be output of the
following c code?
#include <stdio.h>
int main(){
char *str= "cquestionbank" ;
printf( "%s" ,str);
return 0;
}
int printf( char const *str,...){
puts(str);
return 0;
}
20.
What will be output of the
following c code?
#include <stdio.h>
int main(){
auto val=-25;
auto num= 25;
printf( "%+d\t" ,val);
printf( "%#x\t" ,val);
printf( "% d" ,num);
return 0;
}
If you have any quires or suggestions
in above printf function or input or
output (I/O) questions in c, you can ask here.
1 comment:
hebrew translation It's good to see this information in your post, i was looking the same but there was not any proper resource.
Post a Comment