NEW
Font size
WorksheetsTechnical Quiz 2022-23
Total questions: 50
Worksheet time: 38mins
What is the syntax to declare a variable in C?
var x;
int x;
declare x;
define x;
Which of the following is not a valid C data type?
int
float
char
string
What is the size of the 'int' data type in C on most systems?
4 bytes
8 bytes
2 bytes
1 byte
Which operator is used for pointer-to-member access in C?
.
->
::
[]
How is a single-line comment written in C?
// Comment
/* Comment */
# Comment
' Comment
Which function is used to allocate memory dynamically in C?
alloc()
malloc()
new()
allocate()
What is the escape sequence for a newline character in C?
\n
\r
\t
\b
What is the result of the expression 5 + 3 * 2 in C?
10
16
11
13
How can you check if two strings are equal in C?
strcmp(str1, str2) == 0
str1 == str2
str1 = str2
str1.equals(str2)
Which library should be included to use the "printf" and "scanf" functions in C?
stdio.h
conio.h
math.h
string.h
What does the "sizeof" operator in C return?
Memory address
Value of the variable
Size of the data type
Index of the element
How do you declare a constant in C?
const int x;
int constant x;
final int x;
#define x 5
Which of the following is not a storage class in C?
auto
static
constant
register
What does the "break" statement do in a loop in C?
Exits the loop and continues with the next iteration.
Exits the loop and terminates the program.
Skips the current iteration and continues with the next one.
Jumps to a labeled statement.
Which header file is used for input and output operations in C?
stdlib.h
conio.h
iostream.h
stdio.h
How do you define a macro in C?
#macro MY_MACRO
define MY_MACRO
#define MY_MACRO
macro MY_MACRO
What is the result of the expression 10 / 3 in C?
3
3.33
3.0
3.3333
What does the "getchar()" function do in C?
Reads a character from the standard input.
Returns the character 'g'.
Gets a random character.
Returns the next character in a file.
How do you include a header file in your C program?
#include "myheader.h"
include "myheader.h"
header "myheader.h"
<myheader.h>
What is the correct way to declare a function in C?
function myFunction() {}
void myFunction() {}
def myFunction() {}
function void myFunction() {}
How do you declare a multi-dimensional array in C?
int myArray[];
int myArray[][];
int myArray[][];
int myArray[3][3];
What does the "NULL" pointer represent in C?
A pointer to the address 0x0000
A pointer to the end of memory
An uninitialized pointer
A pointer to the last allocated memory
What is the primary purpose of the "if" statement in C?
Loop control
Function definition
Conditional execution
Variable declaration
Which of the following is an example of a post-increment operator in C?
x++
++x
x--
--x
What is the purpose of the "return" statement in a function in C?
Print a value to the console
Exit the program
Terminate the current function and return a value
Define a new function
Which C function is used to open a file for reading?
open()
fopen()
read()
getfile()
What is the correct syntax for a "for" loop in C?
for (int i = 0; i < 10; i++)
for (i = 0; i < 10; i++)
for (int i = 0; i < 10)
for (i < 10; int i++)
How do you access the first element of an array in C?
What is the purpose of the "do...while" loop in C?
Execute a block of code repeatedly as long as a condition is true.
Execute a block of code repeatedly a specific number of times.
Execute a block of code once and then check a condition
Execute a block of code only if a condition is true.
Which operator is used to access the value pointed to by a pointer in C?
*
&
->
.
How can you check if a character is a digit in C?
isdigit(char)
char.isDigit()
isNumeric(char)
isnumber(char)
What is the purpose of the "continue" statement in a loop in C?
Exits the loop.
Skips the current iteration and continues with the next one
Continues with the next statement outside the loop.
Halts the program.
Which operator is used for logical AND in C?
&
&&
|
||
What is the result of the expression 5 == 3 in C?
1 (true)
0 (false)
5
3
What is the purpose of the "typedef" keyword in C?
Define a new data type.
Declare a variable.
Create a macro.
Include a header file.
Which function is used to free the memory allocated by "malloc" in C?
free()
clear()
dealloc()
release()
What is the purpose of the "switch" statement in C?
Execute a block of code repeatedly.
Make decisions based on multiple conditions
Create a function.
Define a variable.
Which of the following is an example of a preprocessor directive in C?
int main() {}
#include <stdio.h>
void printHello() {}
int x = 5;
How do you define a constant string in C?
"Hello, World!"
const char message[] = "Hello, World!";
string message = "Hello, World!";
constant char[] message = "Hello, World!";
What is the purpose of the "goto" statement in C?
Jump to a specified label within a function.
Exit a loop.
Define a new function.
Return a value from a function.
Which header file is used for mathematical functions in C?
math.h
stdio.h
string.h
conio.h
How do you declare an array of integers in C with 10 elements?
int array[10];
int array = [10];
int array(10);
array array(10);
What is the purpose of the "break" statement in a "switch" statement in C?
Exits the "switch" statement
Exits the program.
Exits the current iteration of the loop.
Skips the current case and continues with the next one.
How do you get the address of a variable in C?
&x
*x
@x
#x
What is the result of the expression 2 << 2 in C?
8
4
2
6
What is the purpose of the "union" in C?
To define a new data type.
To group variables of different data types into a single memory location.
To perform mathematical operations.
To declare a structure.
How do you pass an array to a function in C?
void myFunction(array)
void myFunction(int array[])
void myFunction(array[])
void myFunction(int[] array)
What is the result of the expression "sizeof(int)" in C?
1
4
2
8
What is the purpose of the "volatile" keyword in C?
To define a constant variable.
To optimize code for faster execution.
To indicate that a variable may be changed outside the program.
To specify a storage class.
How do you define a multi-line comment in C?
// This is a comment
/* This is a comment */
# This is a comment #
' This is a comment '
