Computer Knowledge
Aptitude · Reasoning · English · CS — Corporate & Campus Interview Prep
150 Questions 5 Topics Take Test
Advertisement
Showing 61–70 of 150 questions
Q.61 Medium C Programming
What will be the output of: int x = 5, y = 10; if (x < y) printf("yes"); else printf("no");
A yes
B no
C Compilation error
D No output
Correct Answer:  A. yes
Explanation:

The condition x < y evaluates to true (5 < 10), so the if block executes, printing 'yes'. The else block is skipped.

Take Test
Q.62 Medium C Programming
Which of the following is NOT a valid way to pass arguments to a function in C?
A Pass by value
B Pass by reference
C Pass by pointer
D All are valid
Correct Answer:  B. Pass by reference
Explanation:

C supports pass by value and pass by pointer/address. 'Pass by reference' as a concept exists in C++, not in C. In C, to achieve reference-like behavior, we use pointers.

Take Test
Q.63 Medium C Programming
What will be the result of: int a = 10, b = 3; int c = a % b; printf("%d", c);
A 3
B 1
C 13
D 30
Correct Answer:  B. 1
Explanation:

The modulus operator % returns the remainder of division. 10 % 3 = 1 (since 10 = 3 × 3 + 1). Therefore, c = 1 and the output is 1.

Take Test
Q.64 Medium C Programming
What will be the output of: char ch = 'A'; printf("%d", ch);
A A
B 65
C Error
D 65.0
Correct Answer:  B. 65
Explanation:

When a character is printed using %d format specifier, its ASCII value is printed. The ASCII value of 'A' is 65.

Take Test
Q.65 Medium C Programming
What is the output of: int x = 5; int y = ++x + x++; printf("%d %d", x, y);
A 7 12
B 6 11
C 7 13
D 6 12
Correct Answer:  A. 7 12
Explanation:
Step 1: x=5. Step 2: ++x makes x=6 (pre-increment, used immediately). Step 3: y = 6 + x++ = 6 + 6 = 12. Step 4: x++ increments x to 7 after use. Final: x=7, y=12.
Take Test
Advertisement
Q.66 Medium C Programming
What is the output of: int a = 10, b = 20; a = a ^ b; b = a ^ b; a = a ^ b; printf("%d %d", a, b);
A 10 20
B 20 10
C 0 0
D 20 20
Correct Answer:  B. 20 10
Explanation:

This is XOR swap algorithm. Step 1: a = 10^20. Step 2: b = (10^20)^20 = 10. Step 3: a = (10^20)^10 = 20. Result: a=20, b=10 (values are swapped).

Take Test
Q.67 Medium C Programming
In C, which function is used to read a string from input with space handling?
A scanf("%s", str);
B fgets(str, sizeof(str), stdin);
C gets(str);
D getline(str);
Correct Answer:  B. fgets(str, sizeof(str), stdin);
Explanation:

fgets() is the safe way to read strings including spaces. scanf("%s") stops at whitespace, gets() is deprecated and unsafe due to buffer overflow risks.

Take Test
Q.68 Medium C Programming
What is the purpose of the 'static' keyword when used with a variable inside a function?
A To make the variable global
B To preserve the variable's value between function calls
C To prevent the variable from being modified
D To allocate memory on the stack
Correct Answer:  B. To preserve the variable's value between function calls
Explanation:

A static variable inside a function is initialized only once and retains its value between successive function calls. It has memory allocated in the data segment, not the stack.

Take Test
Q.69 Medium C Programming
Which of the following correctly represents a structure declaration in C?
A struct {int a; char b;} s;
B struct Name {int a; char b;};
C Both A and B are correct
D Neither A nor B is correct
Correct Answer:  C. Both A and B are correct
Explanation:

Both are valid syntax. Option A declares an anonymous structure with immediate variable instantiation. Option B declares a named structure type that can be used later to create variables.

Take Test
Q.70 Medium C Programming
What will be the final value of x: int x = 5; x += 3 * 2; printf("%d", x);
A 16
B 11
C 13
D 36
Correct Answer:  A. 16
Explanation:
Step 1: x = 5. Step 2: 3 * 2 = 6 (multiplication has higher precedence). Step 3: x += 6 means x = x + 6 = 5 + 6 = 11. Wait, let me recalculate: x = 5; x += 6 gives x = 11. The answer should be B (11), not A. Correction: The correct answer is B.
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