

Functions - Programming
Q1: If int is 2 bytes wide.What will be the output of the program?
#include <stdio.h>
void fun(char**);
int main()
{
char *argv[] = {"ab", "cd", "ef", "gh"};
fun(argv);
return 0;
}
void fun(char **p)
{
char *t;
t = (p+= sizeof(int))[-1];
printf("%s\n", t);
}
A ab
B cd
C ef
D gh
ANS:B - cd Since C is a machine dependent language sizeof(int) may return different values. The output for the above program will be cd in Windows (Turbo C) and gh in Linux (GCC). To understand it better, compile and execute the above program in Windows (with Turbo C compiler) and in Linux (GCC compiler). |


For help Students Orientation
Mcqs Questions
One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.