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

11. Find the output #include"stdio.h" void main ( ) { FILE *p; char ch; p=fopen ("raja.txt", "w"); putc (50,p); putc (80, p); putc (70, p); while ((ch=getc(p))!=EOF) putch (ch); fclose (p); }

  • 508070
  • 2pf
  • Compilation error
  • No output
Show Answer Report

12. Which of the following are similar ?

  • printf ("%d", x) and fprintf (stdin, "%d",x)
  • scanf("%d",&x) and fscanf (stdout, "%d",&x)
  • printf ("%d", x) and fprintf(stdout, "%d", x) fprintf (stdout, "%d", x)
  • None of the above
Show Answer Report

13. What is the contents of the file "letter.txt" #include"stdio.h" void main ( ) { FILE *p; char m[ ] = "I \m \the \best"; p=fopen (letter.txt", "w"); fputs (m,p); fclose (p); }

  • I am the best
  • I 0m the 0est
  • i \am \the \best
  • None of these
Show Answer Report

14. On error create ( ) returns

  • NULL
  • 1
  • -1
  • None of these
Show Answer Report

15. The fclose ( ) function

  • closes only one file at a time
  • Closes all the files opened
  • Closes only text file
  • None of these
Show Answer Report

16. The fseek ( ) function

  • Needs 2 arguments
  • Makes the rewind function unnecessary
  • Is meant for checking whether a given file exists or not.
  • Both b and c
Show Answer Report

17. Find the output #include "stdio.h" void main ( ) { FILE *p; printf ("%d %d", stderr->fd, _streams[3].fd); }

  • 2 3
  • 4 4
  • 1 2
  • Compilation error
Show Answer Report

18. How many data members are present in FILE structure ?

  • 7
  • 8
  • 9
  • 10
Show Answer Report

19. MS-WORD is a

  • ASCII file
  • Binary file
  • Bitmap file
  • None of these
Show Answer Report

20. Find the output #include "stdio.h" void main ( ) { FILE *p=0; p++; printf("%d",p); }

  • 8
  • 16
  • Compilation error
  • None of these
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test