RE: If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output? main(int argc, char *argv[]) { int i,j=0; for(i=0;i<argc;i++) j=j+ atoi(argv[i]);
ans: 6
Explanation: converting string "c:myprog.exe 123" to integer will return 0
RE: If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output? main(int argc, char *argv[]) { int i,j=0; for(i=0;i<argc;i++) j=j+ atoi(argv[i]);
initially J 0 then it incremented by the arg value one. now it is 1.then it incremented by the arg value 2. now the value of J is 3. then it's value incremented by the arg value 3. now it's value is 6.now the loop condition over. The J 6.