C-Command Line Arguments Questions and Answers

Take Exam

Command line arguments in C allow passing values to a program at runtime through the main() function parameters argc and argv. This feature is essential for flexible and interactive program execution. Many programming questions and answers in coding interviews test this concept through practical applications and debugging scenarios. This section provides C command line argument questions with answers and explanations, helping learners strengthen their understanding of runtime input handling. These examples are useful for TCS, Tech Mahindra, and Wipro placement exams where efficiency and clarity of coding are tested.

C-Command Line Arguments

Showing 10 of 129 questions

1. The maximum combined length of the command-line arguments including the spaces between adjacent arguments is

  • 128 characters
  • 256 characters
  • 67 characters
  • It may vary from one operating system to another
Show Answer Report

2. According to ANSI specifications which is the correct way of declaring main when it receives command-line arguments?

  • int main(int argc, char *argv[])
  • int main(argc, argv) int argc; char *argv;
  • int main() { int argc; char *argv; }
  • None of above
Show Answer Report

3. What do the 'c' and 'v' in argv stands for?

  • 'c' means argument control 'v' means argument vector
  • 'c' means argument count 'v' means argument vertex
  • 'c' means argument count 'v' means argument vector
  • 'c' means argument configuration 'v' means argument visibility
Show Answer Report

4. Find the output #include "stdio.h" void main ( ) { int x; fopen ("raja.txt","w"); fopen("milu.txt", "w"); x=FOPEN_MAX; printf("%d", x); }

  • 2
  • 7
  • 20
  • None of these
Show Answer Report

5. The files linked and accessed through the library functions are known as

  • Low level files
  • Stream oriented files
  • Library files
  • None of the above
Show Answer Report

6. The files linked and accessed using system calls are known as

  • Stream oriented files
  • System oriented files
  • High level files
  • None of the above
Show Answer Report

7. Find the output #incude "stdio.h" void main () { FILE *p; p=fopen ("raja. txt", "w"); printf("%d", p->fd); }

  • 5
  • 6
  • 7
  • None of these
Show Answer Report

8. What is the content of the file ? #include "stdio.h" void main ( ) { FILE  *p; p=fopen ("letter.txt", "wt"); putc('Go',p); putc ('od',p); rewind(p); putc(Fo',p); putc('Fo',p); fclose(p); }

  • Food
  • FoGood
  • Fo
  • No output
Show Answer Report

9. Which of the following functions is most appropriate for storing numbers in a file ?

  • putc ( )
  • fprintf( )
  • fwrite ( )
  • None of these
Show Answer Report

10. Which of the following is not true about ftell?

  • it is a function
  • Gives the current file position indicator.
  • Can be used to find the size of a file.
  • it is meant for checking whether a given file exists or not.
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test