What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample friday tuesday sunday
/* sample.c */
#include
int main(int sizeofargv, char *argv[])
{
while(sizeofargv)
printf("%s", argv[--sizeofargv]);
return 0;
}
Answer: C
No answer description available for this question.
Enter details here
What are command line arguments?
Answer: A
Command line arguments are the arguments that passed to the main function when the program is starting its execution.
Enter details here
What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog one two three
/* myprog.c */
#include
#include
int main(int argc, char **argv)
{
int i;
for(i=1; i<=3; i++)
printf("%u\n", &argv[i]);
return 0;
}
If the first value printed by the above program is 65517, what will be the rest of output?
Answer: B
No answer description available for this question.
Enter details here
Even if integer/float arguments are supplied at command prompt they are treated as strings.
Answer: A
No answer description available for this question.
Enter details here
What is the output of this C code?
#include
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);
}
void foo(int *p)
{
printf("%d\n", *p);
}
Answer: C
No answer description available for this question.
Enter details here
Which of the following gives the name of the program if the second parameter to the main fucntion is char **argv?
Answer: C
The first string in the list of command line arguments represents the name of the program which can be accessed by using argv[0].
Enter details here
Which of the following is correct about the second parameter of the main function?
Answer: D
All of the statements about the second parameter is correct. It is the collection of character pointers which of which the first represents the name of the program file.
Enter details here
What is the index of the last argument in command line arguments?
Answer: D
No answer description available for this question.
Enter details here
What will be the output of the program
#include
void fun(int);
int main(int argc)
{
printf("%d ", argc);
fun(argc);
return 0;
}
void fun(int i)
{
if(i!=4)
main(++i);
}
Answer: B
No answer description available for this question.
Enter details here
What does the second parameter of the main function represent?
Answer: B
The second argument of the main() function represents the list of command line arguments that are passed.
Enter details here