Q. What does recursion mean in programming?
-
A.
A function calling itself
-
B.
A loop that iterates
-
C.
A data structure
-
D.
A variable declaration
Solution
Recursion in programming refers to a function that calls itself to solve a problem.
Correct Answer:
A
— A function calling itself
Learn More →
Q. What is the correct syntax to include a header file in C?
-
A.
#include <header.h>
-
B.
#include 'header.h'
-
C.
#include header.h
-
D.
#include <header>
Solution
The correct syntax to include a header file in C is #include <header.h>.
Correct Answer:
A
— #include <header.h>
Learn More →
Q. What is the output of the following code: printf("%d", 10 / 3);?
Solution
The output is 3 because in C, dividing two integers results in an integer, truncating any decimal.
Correct Answer:
A
— 3
Learn More →
Q. What is the output of the following code: printf("%d", 5 + 10 * 2);?
Solution
The output is 25 because of operator precedence: 10 * 2 is evaluated first, then 5 is added.
Correct Answer:
C
— 15
Learn More →
Q. What is the purpose of the 'return' statement in a function?
-
A.
To end the program
-
B.
To return a value from a function
-
C.
To declare a variable
-
D.
To create a loop
Solution
The 'return' statement is used to return a value from a function to the caller.
Correct Answer:
B
— To return a value from a function
Learn More →
Q. Which of the following is a valid variable declaration in C?
-
A.
int 1number;
-
B.
float number1;
-
C.
char number#;
-
D.
double number@;
Solution
The valid variable declaration in C is float number1; as variable names cannot start with a digit or contain special characters.
Correct Answer:
B
— float number1;
Learn More →
Q. Which of the following is not a valid pointer declaration in C?
-
A.
int *ptr;
-
B.
float ptr;
-
C.
char *ptr;
-
D.
double *ptr;
Solution
The declaration float ptr; is not a pointer declaration; it is a regular float variable.
Correct Answer:
B
— float ptr;
Learn More →
Showing 1 to 7 of 7 (1 Pages)