C Programming - Command Line Arguments

11.
What will be the output of the program in Turbo C?
#include<stdio.h>

int main(int argc, char *argv, char *env[])
{
    int i;
    for(i=1; i<argc; i++)
        printf("%s\n", env[i]);
    return 0;
}
List of all environment variables
List of all command-line arguments
count of command-line arguments
Error: cannot have more than two arguments in main()
Answer: Option
Explanation:
No answer description is available. Let's discuss.

12.
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample Jan Feb Mar
/* sample.c */
#include<stdio.h>
#include<dos.h>

int main(int arc, char *arv[])
{
    int i;
    for(i=1; i<_argc; i++)
        printf("%s ", _argv[i]);
    return 0;
}
No output
sample Jan Feb Mar
Jan Feb Mar
Error
Answer: Option
Explanation:
No answer description is available. Let's discuss.

13.
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample monday tuesday wednesday thursday
/* sample.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    while(--argc>0)
        printf("%s", *++argv);
    return 0;
}
sample monday tuesday wednesday thursday
monday tuesday wednesday thursday
monday tuesday thursday
tuesday
Answer: Option
Explanation:
No answer description is available. Let's discuss.

14.
If the following program (myproc.c) is present in the directory "C:\TC" then what will be output of the program if run it from DOS shell?
/* myproc.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    printf("%s", argv[0]);
    return 0;
}
SAMPLE.C
C:\TC\MYPROC.EXE
C:\TC
Error
Answer: Option
Explanation:
In order to execute it from DOS shell, we have to run the created EXE file by entering the exe file name as C:\TC>myproc <enter>.

15.
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<stdio.h>

int main(int argc, char *argv[])
{
    int i;
    for(i=1; i<argc; i++)
        printf("%c", argv[i][0]);
    return 0;
}
oot
ott
nwh
eoe
Answer: Option
Explanation:
No answer description is available. Let's discuss.