Computer Knowledge — C Programming
Aptitude · Reasoning · English · CS — Corporate & Campus Interview Prep
60 Questions 5 Topics Take Test
Advertisement
Showing 1–10 of 60 questions in C Programming
Q.1 Easy C Programming
What is the output of the following C code?
int x = 5;
printf("%d", x++);
A 6
B 5
C Compilation error
D Undefined behavior
Correct Answer:  B. 5
Explanation:

The post-increment operator (x++) returns the current value of x before incrementing. So printf prints 5, and then x becomes 6.

Take Test
Q.2 Easy C Programming
Which of the following is the correct syntax to declare a pointer in C?
A int *ptr;
B int& ptr;
C int ^ptr;
D int @ptr;
Correct Answer:  A. int *ptr;
Explanation:

In C, pointers are declared using the asterisk (*) symbol before the variable name. The syntax is 'datatype *pointer_name;'

Take Test
Q.3 Easy C Programming
What will be the size of the following array in bytes?
char arr[10];
A 10 bytes
B 20 bytes
C 40 bytes
D 5 bytes
Correct Answer:  A. 10 bytes
Explanation:

Each char occupies 1 byte in memory. An array of 10 chars will occupy 10 × 1 = 10 bytes.

Take Test
Q.4 Easy C Programming
What is the purpose of the 'void' keyword in C?
A To declare a function that returns nothing
B To declare a generic pointer
C Both A and B
D To declare empty variables
Correct Answer:  C. Both A and B
Explanation:

void is used in two contexts: (1) as a function return type when a function doesn't return a value, and (2) to declare a generic pointer (void *) that can point to any data type.

Take Test
Q.5 Easy C Programming
What is the output of the following C code?
int a = 10, b = 20;
int c = (a > b) ? a : b;
printf("%d", c);
A 10
B 20
C Compilation error
D 30
Correct Answer:  B. 20
Explanation:

The ternary operator (condition ? true_value : false_value) evaluates the condition (a > b). Since 10 is not greater than 20, it returns b which is 20.

Take Test
Advertisement
Q.6 Easy C Programming
What does the strlen() function return?
A Number of characters in a string including null terminator
B Number of characters in a string excluding null terminator
C Size of memory allocated to string
D Address of the first character
Correct Answer:  B. Number of characters in a string excluding null terminator
Explanation:

strlen() returns the length of a string without counting the null terminator ('\0'). For example, strlen("hello") returns 5, not 6.

Take Test
Q.7 Easy C Programming
Which header file is required to use the printf() function in C?
A #include
B #include
C #include
D #include
Correct Answer:  B. #include
Explanation:

The stdio.h header file contains declarations for standard input/output functions like printf() and scanf().

Take Test
Q.8 Easy C Programming
Which of the following is a valid variable name in C?
A 2var
B _variable
C var-name
D var name
Correct Answer:  B. _variable
Explanation:

Variable names in C must start with a letter or underscore, not a digit. _variable is valid. '2var' starts with digit, 'var-name' contains hyphen (invalid), 'var name' contains space (invalid).

Take Test
Q.9 Easy C Programming
What is the return type of the strlen() function?
A void
B char
C int
D float
Correct Answer:  C. int
Explanation:

The strlen() function returns the length of a string as an int value, representing the number of characters.

Take Test
Q.10 Easy C Programming
Which operator has the highest precedence in C?
A Addition (+)
B Multiplication (*)
C Parentheses ()
D Logical AND (&&)
Correct Answer:  C. Parentheses ()
Explanation:

Parentheses () have the highest precedence among all operators in C. They are always evaluated first in any expression.

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