C Programming Multiple Choice Question - Printf & Scanf
This section focuses on the "Printf And Scanf" of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. What is the output of this program?
#include <stdio.h>
int main()
{
printf("variable! %d", x);
return 0;
}
View Answer
2. What is the output of this program?
#include <stdio.h>
int main()
{
int main = 3;
printf("%d", main);
return 0;
}
View Answer
3. What is the output of this program? if input a is 1 and b is 2
#include <stdio.h>
int main()
{
int a, b;
printf("%d", scanf("%d %d",&a,&b));
return 0;
}
View Answer
4. What is the output of this program?
#include <stdio.h>
void main()
{
printf("hello\rworld\n");
printf("hello\b\b\bworld\n");
}
View Answer
5. What is the output of this program?
#include <stdio.h>
int main()
{
int i;
i = printf("letsfindcourse");
i = printf("%d ", i);
printf("%d ", i);
return 0;
}
View Answer
6. Output of this statment is :
printf ( "%d" , printf ( "hello" ) );
View Answer
7. What is the output of this program?
#include <stdio.h>
# define scanf "%s Find best course "
main()
{
printf(scanf, scanf);
return 0;
}
View Answer
8. Which statment is true about the given code ?
#include <stdio.h>
int main()
{
printf("%d", main);
return 0;
}
View Answer
9. What is the output of this program?
#include <stdio.h>
int main()
{
int i;
i = 1, 2, 3;
printf("%d", i);
return 0;
}
View Answer
10. Comment on the given statment:
scanf("%d",i);
View Answer
11. What is the output of this program?
#include <stdio.h>
int main()
{
int x = 1, y = 2;
printf("%d", x, y);
return 0;
}
View Answer
12. What is the output of this program?
#include <stdio.h>
int main()
{
int x = 1, y = 2;
printf("%*d", x, y);
return 0;
}
View Answer
13. What is the output of this program?
#include <stdio.h>
int main()
{
char str[25];
printf(" %d ",printf("c-letsfind"));
return 0;
}
View Answer
14. What is the output of this program?
#include <stdio.h>
# define loop while(true)
int main()
{
loop;
printf("c-letsfind");
return 0;
}
View Answer
15. What is the output of this program?
#include <stdio.h>
int main()
{
printf("%d", 5.00);
return 0;
}
View Answer
16. What is the output of this program?
#include <stdio.h>
int main()
{
printf("%d",5.25);
return 0;
}
View Answer
17. What is the output of this program ?
#include <stdio.h>
int main()
{
int a = 3;
printf("%d");
return 0;
}
View Answer
18. What is the output of this program ?
#include <stdio.h>
int main()
{
char *ptr = "Hello World";
printf(ptr+2);
return 0;
}
View Answer
19. What is the output of this program 32 bit c compiler ?
#include <stdio.h>
int main()
{
int a = 1;
printf("%d %p",a,a);
return 0;
}
View Answer
20. What is the output of this program ?
#include <stdio.h>
static struct student
{
int a;
int b;
}
struct_var{2,3};
int main()
{
printf("%d %d",struct_var.a,struct_var.b);
return 0;
}
View Answer
21. What is the output of the following code?
int main() {
int i=1;
i=2+2*i++;
printf("%d",i);
return 0;
}
View Answer
22. What is the output of the following code?
main ( )
{
int i;
i=1;
i=i+2*i++;
printf( "%d" , i);
}
View Answer
23. What is the output of this program?
main()
{
int i;
i = 2+3, 4>3, 1;
printf( "%d" , i);
}
View Answer
24. What is the output of this program?
main ()
{
int i=5;
printf( "%d %d %d " , i,i<<2,i>>2);
}
View Answer
25. What is the output of this program?
main ( )
{
int i=5;
printf( "%d %d %d " , i,i<<2,i<<2);
}
View Answer
26. What is the output of this program?
int main()
{
int i=5;
printf( "%d %d %d " , i,i<2,i>2);
return 0;
}
View Answer
27. What is the output of this program ?
int main()
{
int i=5;
printf( "%d %d %d " , i,i&&2,i||2);
return 0;
}
View Answer
28. What is the output of this program ?
int main()
{
int i=5;
printf( "%d %d
" , i,i|2);
return 0;
}
View Answer
29. What is the output of this program 32 bit c compiler ?
int main()
{
int i=1;
i=i+i*i++;
printf("%d",i);
return 0;
}
View Answer
30. What is the output of this program ?
int main()
{
int i=-2;
i=i+i*i++;
printf("%d",i);
return 0;
}
View Answer
31. What is the output of the following code?
int main()
{
int k=1;
printf("%d == 1 is" "%s", k, k==1?"TRUE":"FALSE");
return 0;
}\
View Answer
32. What is the output of the following code?
int main()
{
int k=2;
printf("%d == 1 is" "%s", k, k==1?"TRUE":"FALSE");
return 0;
}
View Answer
33. What is the output of this program?
char *str = "char *str = %c%s%c; main(){ printf(str, 4, str, 4);}";
int main()
{
printf(str, 4, str, 4);
return 0;
}
View Answer
34. What is the output of this program?
main ( )
{
float a=4.1589;
printf("%2.3f", a);
return 0;
}
View Answer
35. What is the output of this program?
main ( )
{
float a=4.1589;
printf("%2.1f", a);
return 0;
}
View Answer
36. What is the output of this program?
int main()
{
printf("%c", ~('C'*-1));
return 0;
}
View Answer
37. What is the output of this program?
int main()
{
printf("%c", ~('W'*-1));
return 0;
}
View Answer
38. What is the output of this program ?
int main()
{
char *p;
p="%d";
p++;
p++;
printf(p-2, 13);
return 0;
}
View Answer
39. What is the output of this program 32 bit c compiler ?
int main()
{
printf("%%%%");
return 0;
}
View Answer
40. What is the output of this program ?
int main()
{
int a=250;
printf("%1d<0x1d>", a);
return 0;
}
View Answer
Also check :
Discussion