WorksheetsLogic Gates and Boolean Algebra Problems 3.1-3.3
Total questions: 25
Worksheet time: 13mins
Consider the C code shown in the image: #include
Nothing prints
Hello World 0
"Hello World"
Hello World
Which header file must be included to use printf() and scanf() in a C program?
On a typical 32-bit or 64-bit system, which pairing of C data type and size is most appropriate?
double → 4 bytes
int → 2 bytes
char → 1 byte
float → 8 bytes
Given int a = 5, b = 2; what does printf("%d", a / b); output?
2.5 because it keeps fraction
3 because it rounds to nearest
0 because division needs casting
2 because integer division truncates
Which statement best defines a pointer in C?
A constant storing immutable data
An operator that multiplies numbers
A function returning an integer value
A variable holding a memory address
Select the correct syntax to declare a pointer to an int named ptr.
int *ptr;
int ptr*;
*int ptr;
pointer int ptr;
Consider the code: int a = 10; printf("%d %d", a++, ++a); What is the most appropriate evaluation of this statement in standard C?
It prints 10 12 reliably on all compilers
It is undefined behavior due to multiple increments
It prints 11 11 consistently for defined sequence
It is implementation-defined but still well-defined
In C, what does writing return 0; at the end of main() indicate to the operating system?
Program paused awaiting user input
Program ended with a failure status code
Program ended successfully with status zero
Program skipped returning any status
What is the output of the following code snippet: int x = 10; printf("%d", x++ + ++x);?
21
19
20
22
Which of the following correctly initializes an array of 10 integers in C?
int arr{10};
int arr[10];
int arr(10);
int arr = new int[10];
What will be the output of the following code: char str[] = "Hello"; printf("%c", str[1]);?
H
l
o
e
What will be the output of the following code snippet: int y = 3; printf("%d", y * 2);?
5
6
3
8
Given float f = 5.5; what does printf("%.1f", f); output?
6
5.50
5.5
5
What will be the output of the following code: int arr[] = {1, 2, 3}; printf("%d", arr[2]);?
1
0
2
3
Which of the following correctly describes the use of the 'sizeof' operator in C?
It is a function to convert data types
It is used to allocate memory dynamically
It returns the number of elements in an array
It returns the size of a variable in bytes
What is the output of the following code snippet: int a = 5; int b = 10; printf("%d", a + b);?
15
5
50
10
What is the output of the following code: int x = 7; printf("%d", x % 3);?
3
0
2
1
Which of the following correctly describes the purpose of the 'break' statement in C?
It exits a loop or switch statement
It terminates the program immediately
It pauses the execution of the program
It skips the current iteration of a loop
What will be the output of the following code: float a = 5.0; float b = 2.0; printf("%.0f", a / b);?
2.5
3
2
5
What is the result of the following code: int a = 5; int b = 3; printf("%d", a - b);?
1
15
8
2
Which of the following correctly declares a function that returns a float in C?
void myFunction(float);
float myFunction();
float: myFunction;
myFunction() float;
What will be the output of the following code: int x = 4; printf("%d", x * x);?
4
16
8
2
What will be the output of the following code: int a = 10; int b = 5; printf("%d", a % b);?
10
5
0
2
Which of the following correctly defines a structure in C?
struct myStruct { int a; };
struct myStruct(int a);
struct myStruct: int a;
myStruct struct { int a; };
What will be the output of the following code: char c = 'A'; printf("%c", c + 1);?
1
C
A
B
