Sail E0 Webinar

MCQs

Total Questions : 29 | Page 1 of 3 pages
Question 1.

Does there exist any way to make the command-line arguments available to other functions 

without passing them as arguments to the function?


  1.    Yes
  2.    No
 Discuss Question
Answer: Option A. -> Yes

Using the predefined variables _argc, _argv. This is a compiler dependent feature. 

It works in TC/TC++ but not in gcc and visual studio.


Question 2.


If the different command line arguments are supplied at different times would the
output of the following program change?


#include<stdio.h>
int main(int argc, char **argv)
{
printf("%d\n", argv[argc]);
return 0;
}
  1.    Yes
  2.    No
 Discuss Question
Answer: Option B. -> No


Question 3.

In Turbo C/C++ under DOS if we want that any wild card characters in the command-line arguments 

should be appropriately expanded, are we required to make any special provision?


  1.    Yes
  2.    No
 Discuss Question
Answer: Option A. -> Yes

Yes you have to compile a program like
tcc myprog wildargs.obj


Question 4.

The first argument to be supplied at command-line must always be count of total arguments


  1.    True
  2.    False
 Discuss Question
Answer: Option B. -> False


Question 5.

Even if integer/float arguments are supplied at command prompt they are treated as strings.


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True


Question 6.

Which of the following is TRUE about argv?


  1.    It is an array of character pointers
  2.    It is a pointer to an array of character pointers
  3.    It is an array of strings
  4.    None of above
 Discuss Question
Answer: Option A. -> It is an array of character pointers


Question 7.

Every time we supply new set of values to the program at command prompt, we need to 

recompile the program.


  1.    True
  2.    False
 Discuss Question
Answer: Option B. -> False


Question 8.


Which of the following statements are FALSE about the below code?


int main(int ac, char *av[])
{
}
  1.    ac contains count of arguments supplied at command-line
  2.    av[] contains addresses of arguments supplied at a command line
  3.    In place of ac and av, argc and argv should be used.
  4.    The variables ac and av are always local to main()
 Discuss Question
Answer: Option C. -> In place of ac and av, argc and argv should be used.


Question 9.


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


/* myprog.c */
#include<stdio.h>
int main(int argc, char **argv)
{
int i;
for(i=0; i
  1.    10 20 30
  2.    myprog 10 20
  3.    myprog 10 20 30
  4.    10 20
 Discuss Question
Answer: Option C. -> myprog 10 20 30


Question 10.


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>
#include<r;stdlib.h>
int main(int argc, char **argv)
{
int i;
for(i=1; i
  1.    65525 65531
  2.    65519 65521
  3.    65517 65517
  4.    65521 65525
 Discuss Question
Answer: Option B. -> 65519 65521


Latest Videos

Latest Test Papers