Question discussion

The following C program is compiled to a.out and then run from the shell with the command ./a.out hello world. What is the output?#include…

2559Medium DSSSB TGT Computer Science 0 replies 1 views
0

The following C program is compiled to a.out and then run from the shell with the command ./a.out hello world. What is the output?

#include <stdio.h>
int main(int argc, char *argv[]) {
    printf("%d", argc);
    return 0;
}
  • A1
  • B3
  • C2
  • D4
Correct answer: B

Explanation

argc counts all the words of the command line including the program name itself, so ./a.out, hello and world give argc = 3.

Discussion 0

Nobody has replied yet. Start the discussion!