int chk (int, int);
include <stdio.h>
int j;
int function;
int main
{
int x;
x = validate(10, 20);
printf("x=%d\n", x);
return 0;
}
int validate(int a, int b)
{
int y, z;
y = &a;
z = &b;
return a >= 45 ? (y) : (z);
}
int main
{
while(j)
{
function;
main;
}
printf("Hi\n");
return 0;
}
int function
{
printf("Hello");
}
Example
- Hello Hi
- No output
- Infinite loop
The correct option is (a).
Explanation:
Declare the integer variable j in Step 1.
Declare the function `function` without any parameters and specify that it returns an integer value by using the `int` keyword.
While the value of j is not initialized, the while condition evaluates to false, leading to the non-execution of the while block.
In Step 4, the printf function is used to display the string "Hi" with a newline character.
Therefore the output of the program is "Hi".
## 18) The C library function rewind() is used for re-position the file pointer at the beginning of the file.
- True
- False
The correct option is (a).
Explanation:
In C, the rewind function moves the file position back to the start of the file associated with the specified stream.
The syntax of using function rewind() is:
void rewind(FILE *stream)
This function additionally removes the error and end-of-file flags for the stream.
## 19) Which header file is used for supporting the functions- malloc() and calloc().
- stdio.h
- math.h
- stdlib.h
- memory.h
The correct option is (c).
Explanation:
The function calloc() necessitates two arguments of type size_h.
The function malloc() necessitates a single argument of type size_h.
To utilize the functions malloc() and calloc(), you need to include the stdlib.h header file.
## 20) A function can execute faster than a macro.
- True
- False
The correct option is (b).
Explanation:
Macros can run more efficiently without the additional burden of context switching since the macro's code is expanded directly at the point of invocation.
Therefore, the above statement is false.