Home > C Programming > Quizzes > C Programming Practice Test: Data Types, Operators and Expressions
C Programming Practice Test: Data Types, Operators and Expressions
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 30% Most missed: “Are logical operator sequence points?”
Quiz questions on: Variable names, datatypes, constants, declarations, arithmetic operators, relational and logical operators, type conversions, bitwise operators, assignment operators, increment and decrement operators, conditional expressions, evaluation order and precedence. Data Types C has four basic data types: Char: This data type stores a single character. It can be signed or unsigned. Int: This data type stores an integer. It can be signed or unsigned. Float: This data type stores a floating-point number. Double: This data type stores a double-precision floating-point... Show more
C Programming Practice Test: Data Types, Operators and Expressions
Time left 00:00
25 Questions

1. What will be the output of the following C code?
#include
int main()
{
int i = 2;
int j = ++i + i;
printf("%d\n", j);
}
2. What will be the output of the following C code?
#include
void main()
{
float x = 0.1;
if (x == 0.1)
printf("Fatskills");
else
printf("Advanced C Classes");
}
3. Which of the following is an invalid assignment operator?
4. Which is valid C expression?
5. All keywords in C are in ____________
6. What will be the output of the following C code?
#include
void main()
{
double x = 123828749.66;
int y = x;
printf("%d\n", y);
printf("%lf\n", y);
}
7. What will be the output of the following C code?
#include
void main()
{
char a = 'a';
int x = (a % 10)++;
printf("%d\n", x);
}
8. The name of the variable used in one function cannot be used in another function.
9. What will be the output of the following C code?

#include
int main()
{
int i = -5;
i = i / 3;
printf("%d\n", i);
return 0;
}
10. What will be the output of the following C code?
#include
int main()
{
unsigned int a = 10;
a = ~a;
printf("%d\n", a);
}
11. What will be the output of the following C code?
#include
void main()
{
int a = -5;
int k = (a++, ++a);
printf("%d\n", k);
}
12. What is the difference between the following 2 codes?
#include //Program 1
int main()
{
int d, a = 1, b = 2;
d = a++ + ++b;
printf("%d %d %d", d, a, b);
}

#include //Program 2
int main()
{
int d, a = 1, b = 2;
d = a++ +++b;
printf("%d %d %d", d, a, b);
}
13. Which data type is most suitable for storing a number 65000 in a 32-bit system?
14. What will be the output of the following C code?
#include
int main()
{
int a = 4, n, i, result = 0;
scanf("%d", n);
for (i = 0;i < n; i++)
result += a;
}
15. What will be the final value of x in the following C code?
#include
void main()
{
int x = 5 * 9 / 3 + 9;
}
16. What will be the output of the following C code?
#include
int main()
{
char c;
int i = 0;
FILE *file;
file = fopen("test.txt", "w+");
fprintf(file, "%c", 'a');
fprintf(file, "%c", -1);
fprintf(file, "%c", 'b');
fclose(file);
file = fopen("test.txt", "r");
while ((c = fgetc(file)) != -1)
printf("%c", c);
return 0;
}
17. Do logical operators in the C language are evaluated with the short circuit?
18. What will be the output of the following C code?
#include
int main()
{
int x = -2;
x = x >> 1;
printf("%d\n", x);
}
19. What will be the output of the following C code?
#include
int main()
{
int x = 2, y = 1;
x *= x + y;
printf("%d\n", x);
return 0;
}
20. Which of the following cannot be a variable name in C?
21. What will be the output of the following C code snippet?
#include
void main()
{
unsigned int x = -5;
printf("%d", x);
}
22. What will be the output of the following C code?
#include
void main()
{
int k = 8;
int x = 0 == 1 && k++;
printf("%d%d\n", x, k);
}
23. What will be the output of the following C code?
#include
int main()
{
int y = 1;
if (y & (y = 2))
printf("true %d\n", y);
else
printf("false %d\n", y);
 
}
24. What will be the output of the following C code?
#include
int main()
{
int a = 1, b = 1, d = 1;
printf("%d, %d, %d", ++a + ++a+a++, a++ + ++b, ++d + d++ + a++);
}
25. What will be the output of the following C code?
#include
int main()
{
int a = 10, b = 5, c = 3;
b != !a;
c = !!a;
printf("%d\t%d", b, c);
}