UGC NET CS 2009 Dec-Paper-2
October 10, 2023
NVS PGT CS 2019 Part-A
October 10, 2023
UGC NET CS 2009 Dec-Paper-2
October 10, 2023
NVS PGT CS 2019 Part-A
October 10, 2023

UGC 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);

}
A
123
B
6
C
Error
D
“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.
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.

Leave a Reply

Your email address will not be published. Required fields are marked *