C Programming - Command Line Arguments - Discussion

Discussion Forum : Command Line Arguments - Find Output of Program (Q.No. 18)
18.
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<stdio.h>

int main(int sizeofargv, char *argv[])
{
    while(sizeofargv)
        printf("%s", argv[--sizeofargv]);
    return 0;
}
sample friday tuesday sunday
sample friday tuesday
sunday tuesday friday sample
sunday tuesday friday
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
11 comments Page 2 of 2.

Vishal said:   8 years ago
@Jyotir Mishra.

The "sample" is the name of the program. So the number of arguments is 4 not 5.


Post your comments here:

Your comments will be displayed after verification.