void fun(char**);
void fun(char **x)
{
char *y;
y = (x += sizeof(int))[-1];
printf("%s\n", y);
}
Example
The correct option is (c).
Explanation:
The output of the above program will be ef in Windows (Turbo C) and ab in Linux (GCC).
Since C is a machine dependent language therefore sizeof(int) may return different values in different operating system.
In Windows operating system sizeof(int)=2 bytes.
In Linux operating system sizeof(int)=4 bytes.
The given size of int is 2 bytes therefore program output is based on the Windows (Turbo C) compiler. Therefore the output of program is ef.
## 12) Find out the error in the below program?
include<stdio.h>
void f1
{
printf("Greetings");
}
Example
- Error: Doesn't print anything
- Error: Not allowed assignment
- No error
- None of the above
The correct option is (b).
Explanation:
The void f() function is not visible to the compiler while going through main() function.
Hence we need to declare this prototype void f(); before the main() function. This kind of error is not occurring in modern compiler.
Therefore on compiling the above program it give Error: Not allowed assignment.
## 13) Which statement is correct about the below program?
include<stdio.h>
The code snippet above demonstrates a simple C program that includes a function prototype for a multiplication function. The main function is used to print the memory address of the main function itself.
int main
{
int x = 5, y = 4, z;
z = multiply(x, y);
printf("z = %d\n", z);
return 0;
}
int multiply(int x, int y)
{
return (x * y);
return (x - y); / Warning: Unreachable code /
}
Output:
z = 20