C Programming
C language from basics to advanced placement prep
1,000 Questions 10 Topics Take Test
Advertisement
Showing 961–970 of 1,000 questions
Q.961 Easy Basics & Syntax
What is the size of 'char' data type in C?
A 2 bytes
B 4 bytes
C 1 byte
D 8 bytes
Correct Answer:  C. 1 byte
EXPLANATION

The 'char' data type in C occupies 1 byte of memory and can store a single character.

Take Test
Q.962 Easy Basics & Syntax
Which of the following is the correct syntax to declare a pointer to an integer in C?
A int *ptr;
B int& ptr;
C *int ptr;
D ptr *int;
Correct Answer:  A. int *ptr;
EXPLANATION

In C, a pointer to an integer is declared using 'int *ptr;' where '*' indicates pointer declaration.

Take Test
Q.963 Medium Basics & Syntax
In C, what is the purpose of the 'static' keyword when used with a global variable?
A To make it accessible only within the current file
B To allocate it on the stack
C To make it a constant
D To prevent memory deallocation
Correct Answer:  A. To make it accessible only within the current file
EXPLANATION

When 'static' is used with a global variable, it restricts its scope to the current file (internal linkage), making it not accessible from other files.

Take Test
Q.964 Hard Basics & Syntax
What will be the output of the following code?
#include
int main() {
int x = 5;
int y = ++x * ++x;
printf("%d", y);
return 0;
}
A 42
B 49
C Undefined behavior
D Runtime Error
Correct Answer:  C. Undefined behavior
EXPLANATION

The expression ++x * ++x modifies x twice without an intervening sequence point, causing undefined behavior.

Take Test
Q.965 Easy Basics & Syntax
What is the output of the following code?
#include
int main() {
char c = 'A';
printf("%d", c);
return 0;
}
A 65
B A
C 1
D Error
Correct Answer:  A. 65
EXPLANATION

The %d format specifier prints the ASCII value of the character. 'A' has ASCII value 65.

Take Test
Advertisement
Q.966 Medium Basics & Syntax
Which memory segment stores global variables in C?
A Stack
B Heap
C Data segment
D Code segment
Correct Answer:  C. Data segment
EXPLANATION

Global variables are stored in the data segment (also called BSS segment for uninitialized globals). Local variables use the stack.

Take Test
Q.967 Hard Basics & Syntax
Which of the following correctly declares a function pointer?
A int *func;
B int (*func)();
C int func*();
D int *func();
Correct Answer:  B. int (*func)();
EXPLANATION

Function pointers require parentheses around the pointer name: int (*func)(). Option D declares a function returning int pointer, not a function pointer.

Take Test
Q.968 Hard Basics & Syntax
What is the main difference between #define and const in C?
A #define is preprocessed while const is handled by compiler
B const occupies memory while #define does not
C Both A and B
D There is no difference
Correct Answer:  C. Both A and B
EXPLANATION

#define is a preprocessor directive replaced before compilation, while const creates an actual variable. const occupies memory; #define does not.

Take Test
Q.969 Easy Basics & Syntax
What will be printed by the following code?
#include
int main() {
char str[] = "Hello";
printf("%c", str[1]);
return 0;
}
A H
B e
C l
D o
Correct Answer:  B. e
EXPLANATION

String indexing starts at 0. str[0] = 'H', str[1] = 'e'.

Take Test
Q.970 Medium Basics & Syntax
Which of the following is NOT a valid data type modifier in C?
A unsigned long
B signed double
C long float
D unsigned char
Correct Answer:  C. long float
EXPLANATION

The 'long' modifier cannot be used with 'float'. You can only use 'double' or 'long double' for longer floating-point types.

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