C Programming
C language from basics to advanced placement prep
1,000 Questions 10 Topics Take Test
Advertisement
Showing 981–990 of 1,000 questions
Q.981 Medium Basics & Syntax
What is the purpose of the void keyword in C?
A To declare empty variables
B To indicate absence of type or empty parameter list
C To declare null pointers
D To terminate a program
Correct Answer:  B. To indicate absence of type or empty parameter list
EXPLANATION

void indicates absence of a return type (void function) or an empty parameter list func(void). It can also represent a generic pointer (void *).

Take Test
Q.982 Hard Basics & Syntax
Which storage class has a default value of 0 if not explicitly initialized?
A auto
B register
C static
D extern
Correct Answer:  C. static
EXPLANATION

Static variables are initialized to 0 by default. auto and register variables have garbage values if not initialized. extern variables are declared elsewhere.

Take Test
Q.983 Medium Basics & Syntax
What is the output of: printf("%f", 7/2);
A 3.5
B 3.0
C 3
D undefined
Correct Answer:  B. 3.0
EXPLANATION

7/2 performs integer division resulting in 3. Using %f format specifier prints it as 3.0 (or similar float representation).

Take Test
Q.984 Hard Basics & Syntax
Consider the expression: int arr[5]; What does arr represent without the index?
A The first element of array
B Base address of the array
C Error - incomplete expression
D The entire array as a single value
Correct Answer:  B. Base address of the array
EXPLANATION

In C, the array name arr (without index) decays to a pointer to its first element, representing the base address.

Take Test
Q.985 Medium Basics & Syntax
What is the scope of a variable declared inside a function in C?
A Global scope
B File scope
C Function scope (local)
D Extern scope
Correct Answer:  C. Function scope (local)
EXPLANATION

Variables declared inside a function have local scope and are only accessible within that function.

Take Test
Advertisement
Q.986 Medium Basics & Syntax
Which of the following correctly represents a character constant in C?
A "A"
B 'A'
C A
D 'AB'
Correct Answer:  B. 'A'
EXPLANATION

Character constants in C use single quotes ('A'). Double quotes ("") are for string literals. A single character in double quotes is a string, not a character constant.

Take Test
Q.987 Medium Basics & Syntax
What will happen if we try to modify a const variable in C?
A Runtime error
B Compilation error
C It will modify successfully
D No error, but warning
Correct Answer:  B. Compilation error
EXPLANATION

Attempting to modify a const variable results in a compilation error as const variables are read-only.

Take Test
Q.988 Medium Basics & Syntax
What is the difference between declaration and definition in C?
A They are the same thing
B Declaration introduces a name; definition allocates memory
C Declaration allocates memory; definition introduces a name
D No difference in C
Correct Answer:  B. Declaration introduces a name; definition allocates memory
EXPLANATION

Declaration tells the compiler about a variable's existence (e.g., 'extern int x;'). Definition allocates actual memory (e.g., 'int x = 5;').

Take Test
Q.989 Medium Basics & Syntax
Consider: void func(int *p); Which statement is correct about this function declaration?
A func takes an integer as parameter
B func takes a pointer to integer as parameter
C func returns a pointer
D func cannot be called
Correct Answer:  B. func takes a pointer to integer as parameter
EXPLANATION

The * in the parameter declaration indicates that func takes a pointer to an integer, not an integer value.

Take Test
Q.990 Medium Basics & Syntax
What is the return type of strlen() function?
A int
B char
C size_t
D float
Correct Answer:  C. size_t
EXPLANATION

strlen() returns size_t, which is an unsigned integer type used for sizes and counts.

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