C Programming and Technical Programming Program

Q. main()
{
show();
}
void show()
{
printf("I'm the greatest");
}

A. Compier error: Type mismatch in redeclaration of show.

Explanation: When the compiler sees the function show it doesn't know anything about it. So
the default return type (ie, int) is assumed. But when compiler sees the actual definition of show
mismatch occurs since it is declared as void. Hence the error.
The solutions are as follows:
1. declare void show() in main() .
2. define show() before main().
3. declare extern void show() before the use of show().

Read Solution (Total 0)

C Other Question

Q. main()
{
printf("%d", out);
}i
nt out=100;

A. Compiler error: undefined symbol out in function main.

Explanation: The rule is that a variable is available for use from the point of declaration. Even
though a is a global variable, it is not available for main. Hence an error.
output?

Q. main( )
{i
nt a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf(%u %u %u %d n,a,*a,**a,***a);
printf(“%u %u %u %d n”,a+1,*a+1,**a+1,***a+1);
}
Answer:
100, 100, 100, 2
114, 104, 102, 3
Explanation: The given array is a 3-D one. It can also be viewed as a 1-D array.
100 102 104 106 108 110 112 114
116 118 120 122
thus, for the first printf statement a, *a, **a give address of first element. since the indirection
***a gives the value. Hence, the first line of the output.
for the second printf a+1 increases in the third dimension thus points to value at 114, *a+1
increments in second dimension thus points to 104, **a +1 increments the first dimension thus
points to 102 and ***a+1 first gets the value at first location and then increments it by 1. Hence,
the output.