What will be the output of the following C code (run without any command line arguments)?
#include
int main(int argc, char *argv[])
{
while (*argv != NULL)
printf("%s\n", *(argv++));
return 0;
}
Answer: B
No answer description available for this question.
Enter details here
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample one two three
/* sample.c */
#include
int main(int argc, char *argv[])
{
int i=0;
i+=strlen(argv[1]);
while(i>0)
{
printf("%c", argv[1][--i]);
}
return 0;
}
Answer: C
No answer description available for this question.
Enter details here
What will be the output of the following C code?
#include
main()
{
typedef int a;
a b=2, c=8, d;
d=(b*2)/2+8;
printf("%d",d);
}
Answer: A
In the code shown above, the keyword typedef is used to give an alias name (a) to an identifier of the type int. The expression on evaluation gives the answer 10. Hence the output of the code shown above is 10.
Enter details here
What is the output of this C code?
#include
void foo(float *);
int main()
{
int i = 10, *p = &i;
foo(&i);
}
void foo(float *p)
{
printf("%f\n", *p);
}
Answer: B
No answer description available for this question.
Enter details here
What is the output of this C code?
#include
int x = 0;
void main()
{
int *ptr = &x;
printf("%p\n", ptr);
x++;
printf("%p\n ", ptr);
}
Answer: A
No answer description available for this question.
Enter details here
What will be the output of the following C code (run without any command line arguments)?
#include
int main(int argc, char *argv[])
{
while (argv != NULL)
printf("%s\n", *(argv++));
return 0;
}
Answer: A
No answer description available for this question.
Enter details here