Computer Knowledge — C Programming
Programming, networking, database and OS questions
60 Questions 5 Topics Take Test
Advertisement
Showing 1–10 of 60 questions in C Programming
Q.1 Easy C Programming
Which header file must be included to use the printf() function in C?
A #include
B #include
C #include
D #include
Correct Answer:  B. #include
EXPLANATION

The printf() function is defined in the Standard Input/Output library. Therefore, '#include <stdio.h>' must be included at the beginning of the program to use printf() and other I/O functions like scanf(), getchar(), putchar(), etc.

Take Test
Q.2 Easy C Programming
What will be the value of 'x' after execution of the following code? int x = 10; x += 5; x *= 2;
A 15
B 30
C 50
D 20
Correct Answer:  B. 30
EXPLANATION
Step 1: x = 10 initially. Step 2: x += 5 means x = x + 5 = 10 + 5 = 15. Step 3: x *= 2 means x = x * 2 = 15 * 2 = 30. Therefore, x = 30.
Take Test
Q.3 Easy C Programming
What is the purpose of the strlen() function in C?
A To compare two strings
B To find the length of a string
C To copy one string to another
D To concatenate two strings
Correct Answer:  B. To find the length of a string
EXPLANATION

The strlen() function returns the number of characters in a string, excluding the null terminator ('\0').

Take Test
Q.4 Easy C Programming
What is the output of the following C code?
int main() {
int a = 10;
printf("%d", a += 5);
return 0;
}
A 10
B 15
C 5
D Compilation Error
Correct Answer:  B. 15
EXPLANATION

The += operator adds 5 to a (a = a + 5 = 10 + 5 = 15), and printf prints the updated value 15.

Take Test
Q.5 Easy C Programming
In the expression: int arr[3][3]; arr[1][2] = 5; What is being accessed?
A Element in row 1, column 2
B Element in row 2, column 3
C Element in row 2, column 1
D Invalid access - syntax error
Correct Answer:  A. Element in row 1, column 2
EXPLANATION

In C, array indices are 0-based. arr[1][2] refers to the element in the second row (index 1) and third column (index 2) of the 2D array.

Take Test
Advertisement
Q.6 Easy C Programming
Which function is used to read a single character from standard input?
A scanf()
B getchar()
C gets()
D fgetc()
Correct Answer:  B. getchar()
EXPLANATION

getchar() reads a single character from standard input (stdin). While fgetc() can also read a character, getchar() is the standard dedicated function for this purpose.

Take Test
Q.7 Easy C Programming
What is the correct way to declare a pointer to an integer?
A int p*;
B int *p;
C *int p;
D pointer int p;
Correct Answer:  B. int *p;
EXPLANATION

The correct syntax is 'int *p;' where int is the data type, * indicates pointer, and p is the pointer variable name.

Take Test
Q.8 Easy C Programming
What keyword is used to create a pointer variable in C?
A ref
B *
C &
D ptr
Correct Answer:  B. *
EXPLANATION

The asterisk (*) symbol is used to declare pointer variables. For example: int *ptr; declares a pointer to an integer.

Take Test
Q.9 Easy C Programming
What will be the output of: printf("%d", 5 + 3 * 2);?
A 16
B 11
C 13
D 18
Correct Answer:  B. 11
EXPLANATION

Operator precedence: multiplication (*) is performed before addition (+). So: 3 * 2 = 6, then 5 + 6 = 11.

Take Test
Q.10 Easy C Programming
Which of the following is NOT a valid variable name in C?
A _myVar
B myVar123
C 123myVar
D my_var
Correct Answer:  C. 123myVar
EXPLANATION

Variable names in C cannot start with a digit. They must begin with a letter (a-z, A-Z) or underscore (_). '123myVar' is invalid.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips