Computer Knowledge
Aptitude · Reasoning · English · CS — Corporate & Campus Interview Prep
309 Questions 5 Topics Take Test
Advertisement
Showing 61–70 of 309 questions
Q.61 Hard C Programming
What happens when you try to access an array element beyond its size in C?
A Compilation error
B Runtime error with exception
C Undefined behavior
D Returns 0 automatically
Correct Answer:  C. Undefined behavior
Explanation:

C does not perform bounds checking on arrays. Accessing beyond array bounds results in undefined behavior - it may access garbage values, crash, or seem to work without error. This is a common source of bugs.

Take Test
Q.62 Medium C Programming
What is the output of: int x = 10; printf("%d", x++); printf("%d", x);
A 1010
B 1011
C 910
D 111
Correct Answer:  B. 1011
Explanation:

x++ is post-increment. First printf uses current value (10), then x is incremented. Second printf uses new value (11). Output: 1011

Take Test
Q.63 Hard C Programming
Which of the following is the correct way to pass a string to a function in C?
A void func(string s);
B void func(char s[]);
C void func(char *s);
D Both B and C
Correct Answer:  D. Both B and C
Explanation:

Both char s[] (array notation) and char *s (pointer notation) are valid ways to pass strings to functions in C. C does not have a built-in string type; strings are represented as character arrays or pointers to char.

Take Test
Q.64 Easy C Programming
What is the size of int data type in a 32-bit system?
A 2 bytes
B 4 bytes
C 8 bytes
D 1 byte
Correct Answer:  B. 4 bytes
Explanation:

In a 32-bit system, the int data type typically occupies 4 bytes (32 bits). This is the standard size for integer types on most 32-bit architectures.

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

The stdio.h (Standard Input Output) header file contains declarations for printf(), scanf(), and other input/output functions. It is essential for console I/O operations.

Take Test
Advertisement
Q.66 Easy C Programming
In C, which operator has the highest precedence?
A Arithmetic operator
B Logical operator
C Parentheses ()
D Assignment operator
Correct Answer:  C. Parentheses ()
Explanation:

Parentheses have the highest precedence in C. Expressions within parentheses are evaluated first, followed by arithmetic operators, then logical operators, and finally assignment operators.

Take Test
Q.67 Easy C Programming
What is the purpose of the break statement in a loop?
A Pause the loop temporarily
B Exit the loop immediately
C Restart the loop
D Skip the current iteration
Correct Answer:  B. Exit the loop immediately
Explanation:

The break statement exits or terminates the current loop immediately. Option D describes continue (which skips to next iteration), while break actually exits the loop.

Take Test
Q.68 Medium C Programming
Which of the following correctly declares a pointer to an integer?
A int *ptr;
B *int ptr;
C ptr *int;
D int ptr*;
Correct Answer:  A. int *ptr;
Explanation:

The correct syntax for declaring a pointer to an integer is 'int *ptr;' where the asterisk (*) indicates that ptr is a pointer. The placement of * before the variable name is crucial.

Take Test
Q.69 Medium C Programming
What will be printed if char ch = 'A'; printf("%d", ch); is executed?
A A
B 65
C 97
D 41
Correct Answer:  B. 65
Explanation:

When %d format specifier is used with a char variable, it prints the ASCII value. The ASCII value of 'A' is 65. If it were 'a', the value would be 97.

Take Test
Q.70 Medium C Programming
Which of the following is used to dynamically allocate memory in C?
A new()
B alloc()
C malloc()
D create()
Correct Answer:  C. malloc()
Explanation:

malloc() (memory allocation) is the standard function in C for dynamic memory allocation. It returns a void pointer to the allocated memory. The syntax is: ptr = (type*)malloc(size);

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