NEW
Font size
WorksheetsC Programming Concepts Worksheet
Total questions: 30
Worksheet time: 30mins
What is the output of sizeof(int) on a 64-bit system?
2
4
8
Depends on compiler
What will happen if free() is called twice on the same pointer?
Memory leak
Undefined behavior
Segmentation fault always
Program runs normally
Which of the following is NOT a valid storage class?
auto
static
register
dynamic
Which operator cannot be overloaded in C?
+
*
=
None (C does not support operator overloading)
Which of the following can cause a segmentation fault?
Dereferencing NULL
Dereferencing uninitialized pointer
Accessing freed memory
All of these
What is the return type of malloc()?
int
void*
char*
float*
Which function moves the file pointer relative to current position?
rewind()
fseek()
ftell()
fmove()
Which macro checks if a file has reached end-of-file?
file_end()
end()
feof()
eof()
What is the output of: printf("%d", 10 << 1);
5
10
20
40
What is the purpose of the restrict keyword?
Makes variable constant
Helps compiler optimize pointer access
Prevents pointer arithmetic
Allocates memory dynamically
What happens if main() has no return statement in C?
Compiler error
Undefined behavior
Returns 0 implicitly
Program crash
What is the output of strcmp("ABC", "ABD")?
0
1
Negative value
Positive value
Which symbol is used to end a statement in C?
A) :
B) ;
C) .
D) ,
Which data type stores a single character?
int
char
float
double
Which function is used to print output?
input()
print()
printf()
scan()
Which header file is required for printf()?
math.h
stdio.h
string.h
conio.h
Which operator is used for division?
/
%
*
//
Which keyword is used to declare a constant?
final
constant
const
static
Which data type stores decimal values?
int
float
char
short
What does the sizeof operator do?
Calculates time
Converts data type
Gives memory size
Prints size on screen
What is the default return type of a function if not specified?
void
int
float
depends on compiler
What is the correct syntax to input an integer x?
scanf("%d", x);
scanf("%d", &x);
scanf("%i", x);
read("%d", &x);
Which escape sequence prints a new line?
\t
\n
\s
\\
In an if condition, which value is treated as false?
1
0
Any non-zero value
None
What is the scope of a variable declared inside a function?
Global
Block (local)
Static
File
Which keyword returns control from a function?
goto
exit
return
break
What happens if a function is called before it is declared?
Compiler error
Linker error
Implicit declaration (deprecated)
Function executes normally
What is the purpose of main() in C?
Program execution starts here
Stores all variable declarations
Calls functions only
Which of the following correctly represents a character constant?
“A”
‘A’
A
(A)
What is the output of strcmp(“Hello”, “Hello”)?
0
1
-1
Undefined
