Home Subjects Computer Knowledge C Programming

Computer Knowledge
C Programming

Programming, networking, database and OS questions

200 Q 2 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 141–150 of 200
Topics in Computer Knowledge
All C Programming 200 Database/SQL 100
Q.141 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.142 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.143 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.144 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.145 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
Q.146 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.147 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.148 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.149 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.150 Medium C Programming
What is the output of the following code?
for(int i = 1; i
A 1 2 3
B 1 3
C 2 3
D 1
Correct Answer:  B. 1 3
EXPLANATION

When i = 1, it prints 1. When i = 2, continue skips the printf() and moves to the next iteration. When i = 3, it prints 3. Output: 1 3

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