0% found this document useful (0 votes)
13 views5 pages

C Test 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

C Test 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Which operator in C is used for logical AND?

a) &&
b) &
c) ||
d) |

What is the C keyword used to define a structure?


a) struct
b) define
c) structure
d) typedef

What is the default return type of a C function if not specified?


a) void
b) int
c) float
d) char

What is the purpose of the 'goto' statement in C?


a) Loop control
b) Function declaration
c) Code branching
d) Variable declaration

In C, what is the operator for the modulus operation?


a) %
b) /
c) *
d) &

Which C header file should be included to use the 'sqrt' function?


a) math.h
b) stdio.h
c) conio.h
d) cmath.h

What is the ternary operator in C?


a) ?
b) :
c) ;
d) ,
How do you declare a pointer to an integer in C?
a) int* ptr;
b) pointer int;
c) int ptr;
d) int& ptr;

What is the purpose of the 'sizeof' operator in C?


a) Return the size of a variable
b) Perform arithmetic operations
c) Declare a variable
d) Allocate memory

What does the 'static' keyword do when used with a global variable in C?
a) Makes the variable constant
b) Limits the variable's scope to the current function
c) Retains the variable's value between function calls
d) Changes the data type of the variable

In C, which symbol is used to indicate a single-line comment?


a) //
b) /*
c) #
d) --

What is the purpose of the 'sizeof' operator in C?


a) Return the size of a variable
b) Perform arithmetic operations
c) Declare a variable
d) Allocate memory

Which data type in C is used to store characters?


a) char
b) int
c) float
d) double

What does the 'continue' statement do in a loop in C?


a) Exit the loop
b) Skip the current iteration and continue with the next one
c) Print a message
d) Pause the loop temporarily

Which library function is used to read a character from the standard input in C?
a) scanf
b) gets
c) getchar
d) readchar

How is memory allocated for a C structure?


a) Automatically by the compiler
b) Using the 'malloc' function
c) Dynamically during runtime
d) Memory is not allocated for structures

What is the purpose of the 'union' in C?


a) To define a data structure with multiple members
b) To define a data structure that can hold different data types at the same time
c) To define a constant value
d) To declare a variable

Which C function is used to open a file for writing?


a) open
b) fopen
c) write
d) create

What is the result of the expression '5 + 2 * 3' in C?


a) 11
b) 21
c) 15
d) 10

What is the purpose of the 'void' keyword in C function declarations?


a) It specifies the return type of the function.
b) It indicates that the function has no arguments.
c) It specifies that the function cannot have local variables.
d) It indicates that the function does not return any value.

What is the escape sequence for a newline character in C?


a) \n
b) \t
c) \r
d) \
Which header file should be included to work with dynamic memory allocation functions
like 'malloc' and 'free'?
a) stdlib.h
b) malloc.h
c) memory.h
d) alloc.h

In C, what is the purpose of the 'volatile' keyword?


a) To indicate that a variable cannot be changed
b) To specify that a variable's value may change at any time
c) To make a variable constant
d) To declare a variable

What is the purpose of the 'enum' keyword in C?


a) To define a structure
b) To define a union
c) To define a constant
d) To define a set of named integer constants

What does the 'sizeof' operator return in C?


a) Memory address of a variable
b) Size of the largest variable in the program
c) Size in bytes of a data type or object
d) The ASCII code of a character

Which C standard library function is used to sort an array of integers in ascending


order?
a) sort
b) bubbleSort
c) qsort
d) arraySort

What is the purpose of the 'register' keyword in C?


a) To declare a global variable
b) To declare a variable in the heap
c) To declare a variable in the stack
d) To suggest that a variable should be stored in a register for faster access

Which data type is used to represent a single character in C?


a) char
b) int
c) float
d) double
What is the output of the following C code?

c
Copy code
int x = 5;
printf("%d", x++);
a) 5
b) 6
c) 7
d) 4

What is the result of the expression '10 % 3' in C?


a) 0
b) 1
c) 2
d) 3

You might also like