NEW
Font size
WorksheetsC Programming Fundamentals
Total questions: 23
Worksheet time: 12mins
What will be the output of the following code snippet: int a = 5; if(a > 3) { printf("Hello"); } else { printf("World"); }
Greetings
Salutations
Hello
Hi
Identify the data type of the variable 'x' in the following code: float x = 10.5;
int
float
string
double
What is the result of the following expression: 10 / 3?
4.0
2.5
3.5
3.3333
What will be the output of the following code: int a = 10; a++; printf("%d", a);
11
10
9
12
What is the purpose of the switch statement in C?
To create loops in C programming.
To define functions in C.
To handle errors in C code.
The purpose of the switch statement in C is to simplify multi-way branching based on the value of a variable.
What will be the output of the following code: int a = 5; int b = 10; int c = (a > b) ? a : b; printf("%d", c);
15
10
5
0
What is the result of the following operation: 5 + 2 * 3?
11
8
9
10
What will be the output of the following code: int a = 5; a += 2; printf("%d", a);
7
6
8
5
What is the data type of the variable 'y' in the following code: char y = 'A';
float
char
string
int
What will be the output of the following code: int a = 5; int b = 2; printf("%d", a / b);
1
2.5
3
2
What is the result of the following expression: (float)10 / 3?
3.3333
2.6
4.5
3.0
What will be the output of the following code: int a = 5; a--; printf("%d", a);
3
4
5
0
What is the purpose of type conversion in C?
To create new data types in C
To improve the performance of the program
To reduce the memory usage of variables
The purpose of type conversion in C is to enable operations between different data types and ensure compatibility.
What will be the output of the following code: int a = 5; int b = 10; if(a < b) { printf("True"); } else { printf("False"); }
Maybe
False
True
Not Sure
What is the result of the following operation: 10 % 3?
1
3
10
0
What will be the output of the following code: int a = 5; int b = 5; if(a == b) { printf("Equal"); } else { printf("Not Equal"); }
Equal
Undefined
Not Equal
Error
What is the precedence of the operators in the expression: 2 + 3 * 4?
Addition (+) has higher precedence than multiplication (*).
Multiplication (*) and addition (+) are evaluated from left to right.
Both operators have the same precedence.
Multiplication (*) has higher precedence than addition (+).
What will be the output of the following code: int a = 5; int b = 3; printf("%d", a - b++);
5
2
3
1
What is the result of the following expression: (int)5.7 + (int)2.3?
9
7
6
8
What will be the output of the following code: switch(a) { case 1: printf("One"); break; case 2: printf("Two"); break; default: printf("Default"); } where a = 3?
Two
One
Three
Default
What will be the output of the following code: int a = 10; int b = 5; printf("%d", a % b);
1
0
5
2
What is the result of the following expression: (double)9 / 4?
2.5
2.0
2.25
3.0
What will be the output of the following code: int a = 3; int b = 4; printf("%d", a * b + a);
12
15
7
10
