C Programming :: Command Line Arguments

Home > C Programming > Command Line Arguments > General Questions

1 / 15

 which is the correct way of declaring main() when it receives comrnand line arguments ?

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

ShortCut

2 / 15

 If the following program (Helloprog) is run from the command line as HelloProg 1 2 3. what would be the output?

main (int argc, char*argv[])
{
int i;
i = argv[1] + argv [2] + argv [3];
printf("%d", i);
}

Answer: Option B

Explanation:

here argv[1] argv [2] argv [3] are string type. to perform addition  convert it to integer.i=atoi( argv[1]) atoi(argv [2]) atoi( argv [3]).

ShortCut By :: NITISH

here argv[1] argv [2] argv [3] are string type. to perform addition  convert it to integer.i=atoi( argv[1]) atoi(argv [2]) atoi( argv [3]).

Workspace


Tags:  No Tags on this question yet!

3 / 15

 The following 'C' program (dumpProg) is run from the command line as "dumpProg friday tuesday Sunday". what would be the output?

#include
void main (int argc, char*argv[])
{
printf("%c", **++argv);
}

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

4 / 15

 The following program (HelloProg) is run from the command line as HelloProg 1 2 3. what would be the output ?

#include
void main (int argc, char*argv[])
{
int i,j=0;
for (i=0; i < argc; i++)
j = j + atoi (argv[i]);
printf ("%d",j);
}

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

5 / 15

 Maximum combined length of the command line arguments including the spaces between adjacent arguments is

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

6 / 15

 What is the output of the following 'C' program ?

#include
void main (int argc, char*argv[], char*env[])
{
int i;
for (i=1; i printf ("%s", env[i]);
}

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

7 / 15

 If the following program i.e "myprog" is run from the command line as "a.out" . What would be the output?

#include
void main (int argc, char*argvl))
{
int i;
for (i = 1; i < argc; i++)
print[ ("%s", argv[i]);
}

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

8 / 15

 The following 'C' program (dumpProg) is run from the command line as "dumpProg friday tuesday Sunday". what would be the output?

void main (int argc, char*argv[])
{
printf("%c", **++argv);
}

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

9 / 15

 The following 'C' program (dumpProg) is run from the command line as "dumpProg friday tuesday Sunday". what would be the output?

void main (int argc, char*argv[])
{
printf("%c", *++argv[1]);
}

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

10 / 15

 If the following program (myprog) is present in the directory
c:/bc/tuesthen what would be its output ?

main (int argc, char*argv[])
{
printf ("%s", argv[0]);
}

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!