C Programming :: Command Line Arguments - Discussion
Home > C Programming > Command Line Arguments > MCQs Questions Discussion
2 / 15
If the following program (Helloprog) is run from the command line as HelloProg 1 2 3. what would be the output?
#include<stdio.h>
main (int argc, char*argv[])
{
int i;
i = argv[1] + argv [2] + argv [3];
printf("%d", i);
}
#include<stdio.h>
main (int argc, char*argv[])
{
int i;
i = argv[1] + argv [2] + argv [3];
printf("%d", i);
}
A123
BError
C6
DNone of these
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
SHORTCUT
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]).
Read Full Answer
Report Error
Please Login First Click Here