Sail E0 Webinar

MCQs

Total Questions : 29 | Page 2 of 3 pages
Question 11.


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 argc, char *argv[])
{
printf("%c", *++argv[2] );
return 0;
}
  1.    s
  2.    f
  3.    u
  4.    r
 Discuss Question
Answer: Option C. -> u


Question 12.


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;
}
  1.    sample friday tuesday sunday
  2.    sample friday tuesday
  3.    sunday tuesday friday sample
  4.    sunday tuesday friday
 Discuss Question
Answer: Option C. -> sunday tuesday friday sample


Question 13.


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;
}
  1.    SAMPLE.C
  2.    C:TCMYPROC.EXE
  3.    C:TC
  4.    Error
 Discuss Question
Answer: Option B. -> C:TCMYPROC.EXE

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>.


Question 14.


What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample 1 2 3
cmd> sample 2 2 3
cmd> sample 3 2 3


/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%s\n", argv[0]);
return 0;
}
  1.    sample 3 2 3
  2.    sample 1 2 3
  3.    sample
  4.    Error
 Discuss Question
Answer: Option C. -> sample


Question 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
  1.    oot
  2.    ott
  3.    nwh
  4.    eoe
 Discuss Question
Answer: Option B. -> ott


Question 16.


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;
}
  1.    sample monday tuesday wednesday thursday
  2.    monday tuesday wednesday thursday
  3.    monday tuesday thursday
  4.    tuesday
 Discuss Question
Answer: Option B. -> monday tuesday wednesday thursday


Question 17.


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
  1.    No output
  2.    sample Jan Feb Mar
  3.    Jan Feb Mar
  4.    Error
 Discuss Question
Answer: Option C. -> Jan Feb Mar


Question 18.


What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog friday tuesday sunday


/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%c", *++argv[1]);
return 0;
}
  1.    r
  2.    f
  3.    m
  4.    y
 Discuss Question
Answer: Option A. -> r


Question 19.


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 argc, char *argv[])
{
printf("%c", **++argv);
return 0;
}
  1.    s
  2.    f
  3.    sample
  4.    friday
 Discuss Question
Answer: Option B. -> f


Question 20.

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<stdio.h>
int main(int argc, char *argv[])
{
int i=0;
i+=strlen(argv[1]);
while(i>0)
{
printf("%c", argv[1][--i]);
}
return 0;
}
  1.    three two one
  2.    owt
  3.    eno
  4.    eerht
 Discuss Question
Answer: Option C. -> eno


Latest Videos

Latest Test Papers