11. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 3, y = 2;
int z = x /= y %= 2;
printf("%d\n", z);
}
#include <stdio.h>
int main()
{
int x = 3, y = 2;
int z = x /= y %= 2;
printf("%d\n", z);
}
12. What will be the output of the following C code considering the size of a short int is 2, char is 1 and int is 4 bytes?
#include <stdio.h>
int main()
{
short int i = 20;
char c = 97;
printf("%d, %d, %d\n", sizeof(i), sizeof(c), sizeof(c + i));
return 0;
}
#include <stdio.h>
int main()
{
short int i = 20;
char c = 97;
printf("%d, %d, %d\n", sizeof(i), sizeof(c), sizeof(c + i));
return 0;
}
13. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 97;
int y = sizeof(x++);
printf("X is %d", x);
}
#include <stdio.h>
void main()
{
int x = 97;
int y = sizeof(x++);
printf("X is %d", x);
}
14. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int a = 2 + 4 + 3 * 5 / 3 - 5;
printf("%d", a);
}
#include <stdio.h>
void main()
{
int a = 2 + 4 + 3 * 5 / 3 - 5;
printf("%d", a);
}
15. A user defined data type, which is used to assign names to integral constants is called . . . . . . . .
16. What will be the output of the following C code if input given is 2?
#include<stdio.h>
enum day
{
a,b,c=5,d,e
};
main()
{
printf("Enter the value for a");
scanf("%d",a);
printf("%d",a);
}
#include<stdio.h>
enum day
{
a,b,c=5,d,e
};
main()
{
printf("Enter the value for a");
scanf("%d",a);
printf("%d",a);
}
17. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int b = 6;
int c = 7;
int a = ++b + c--;
printf("%d", a);
}
#include <stdio.h>
void main()
{
int b = 6;
int c = 7;
int a = ++b + c--;
printf("%d", a);
}
18. What will be the final values of i and j in the following C code?
#include <stdio.h>
int x = 0;
int f()
{
if (x == 0)
return x + 1;
else
return x - 1;
}
int g()
{
return x++;
}
int main()
{
int i = (f() + g()) | g(); //bitwise or
int j = g() | (f() + g()); //bitwise or
}
#include <stdio.h>
int x = 0;
int f()
{
if (x == 0)
return x + 1;
else
return x - 1;
}
int g()
{
return x++;
}
int main()
{
int i = (f() + g()) | g(); //bitwise or
int j = g() | (f() + g()); //bitwise or
}
19. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int b = 5 & 4 & 6;
printf("%d", b);
}
#include <stdio.h>
void main()
{
int b = 5 & 4 & 6;
printf("%d", b);
}
20. What will be the output of the following C code?
#include <stdio.h>
void main()
{
double b = 5 & 3 && 4 || 5 | 6;
printf("%lf", b);
}
#include <stdio.h>
void main()
{
double b = 5 & 3 && 4 || 5 | 6;
printf("%lf", b);
}
Read More Section(C Fundamentals)
Each Section contains maximum 100 MCQs question on C Fundamentals. To get more questions visit other sections.