UGC NET CS 2009 Dec-Paper-2
October 10, 2023NVS PGT CS 2019 Part-A
October 10, 2023UGC NET CS 2009 Dec-Paper-2
|
Question 12
|
What would be the output of the following program, if run from the command line as “myprog 123”?
main(int argc,char∗argv[ ])
{
int i;
i=argv[1] + argv[2] + argv[3];
printf (“%d”, i);
}
main(int argc,char∗argv[ ])
{
int i;
i=argv[1] + argv[2] + argv[3];
printf (“%d”, i);
}
|
123
|
|
|
6
|
|
|
Error
|
|
|
“123”
|
Question 12 Explanation:
The input given in string type. But we need to print the value in integer type. For this we have to use type casting (or) atoi function. So, it will give output is “error”
Note: argv[1], argv[2] and argv[3] is string type.
Note: argv[1], argv[2] and argv[3] is string type.
Correct Answer: C
Question 12 Explanation:
The input given in string type. But we need to print the value in integer type. For this we have to use type casting (or) atoi function. So, it will give output is “error”
Note: argv[1], argv[2] and argv[3] is string type.
Note: argv[1], argv[2] and argv[3] is string type.
