ExamVeda
Login
Home
11
What is the purpose of the 'break' statement in C?
Discuss
Answer & Solution
Answer: Option D
Solution:
The purpose of the 'break' statement in C is to exit a loop. When 'break' is encountered within a loop (such as 'for' or 'while' loop), it immediately terminates the loop and continues with the next statement after the loop's body.

So, the correct answer is:

Option D: Exit a loop

Here's an example of using the 'break' statement to exit a loop in C:

for (int i = 1; i <= 10; i++) {
    if (i == 5) {
        break; // Exit the loop when i is equal to 5
    }
    printf("%d ", i);
}
12
Which of the following is not a valid C keyword?
Discuss
Answer & Solution
Answer: Option C
Solution:
Among the options provided, Option C: printf is not a valid C keyword.

C keywords are reserved words that have special meanings in the language, and they cannot be used as identifiers (such as variable names or function names). Keywords like 'main,' 'if,' and 'for' are all valid C keywords with specific purposes in the language.

However, 'printf' is not a keyword; it's a standard C library function used for outputting formatted text. It can be used as a function name in C code.

So, the correct answer is:

Option C: printf
13
What is the maximum number of arguments that can be passed to a C function?
Discuss
Answer & Solution
Answer: Option D
Solution:
The maximum number of arguments that can be passed to a C function is Option D: No limit. In C, there is no hard-coded limit on the number of arguments you can pass to a function. However, practical limitations may exist based on factors like system memory and stack size.

So, the correct answer is: Option D: No limit
14
Which operator is used to access the value stored at a pointer address in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
The operator used to access the value stored at a pointer address in C is Option A: *. The asterisk () operator is known as the "dereference" operator, and it is used to retrieve the value that a pointer is pointing to.
15
What does the 'void' keyword indicate in a C function declaration?
Discuss
Answer & Solution
Answer: Option A
Solution:
The 'void' keyword in a C function declaration indicates Option A: Empty return type. When a function is declared with 'void' as its return type, it means that the function does not return any value.
16
Which character is used to represent a comment in C code?
Discuss
Answer & Solution
Answer: Option B
Solution:
The character used to represent a comment in C code is Option B: //. In C, the double forward slash (//) is used to begin a single-line comment. Comments are used for adding explanations or notes within the code that are ignored by the compiler and are solely for human readability.

So, the correct answer is:
Option B: //

Here's an example of a single-line comment in C:
int main() {
    // This is a single-line comment
    printf("Hello, World!");
    return 0;
}
17
What is the purpose of the 'continue' statement in a loop?
Discuss
Answer & Solution
Answer: Option C
Solution:
The purpose of the 'continue' statement in a loop is to skip the current iteration and proceed to the next iteration of the loop. When 'continue' is encountered within a loop, it immediately terminates the current iteration and continues with the next iteration, effectively skipping any remaining code within the current iteration's body.

So, the correct answer is:
Option C: Skip the current iteration
18
What is the range of values that can be stored in an 'int' data type in C?
Discuss
Answer & Solution
Answer: Option B
Solution:
The range of values that can be stored in an 'int' data type in C is Option B: -2147483648 to 2147483647. An 'int' is typically represented as a 32-bit signed integer on most systems, which allows it to store values within this range.

So, the correct answer is:

Option B: -2147483648 to 2147483647
19
Which operator is used to compare two values for equality in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
The operator used to compare two values for equality in C is Option A: ==. The double equal sign (==) is the equality operator, and it is used to check if two values are equal to each other.

So, the correct answer is:
Option A: ==
Here's an example of using the equality operator in C:
int x = 5;
int y = 10;

if (x == y) {
    // This condition will not be met because x is not equal to y
    printf("x is equal to y");
} else {
    printf("x is not equal to y"); // This will be printed
}

In this example, the program checks if 'x' is equal to 'y' using the == operator and prints the result based on the comparison.
20
What is the purpose of the 'const' keyword in C?
Discuss
Answer & Solution
Answer: Option A
Solution:
The purpose of the 'const' keyword in C is to declare a constant. When you use the 'const' keyword before a variable declaration, it indicates that the value of that variable cannot be changed once it is assigned a value. It creates an immutable constant in your code.

So, the correct answer is:
Option A: Declare a constant
Here's an example of using the 'const' keyword to declare a constant in C:
const int max_attempts = 3;

In this example, 'max_attempts' is declared as a constant integer, and its value cannot be modified after initialization.