Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. A program that has no command line arguments will have argc
a) Zero
b) Negative
c) One
d) Two

View Answer

Answer: c [Reason:] None.

2. The index of the last argument in command line arguments is
a) argc – 2
b) argc + 1
c) argc
d) argc – 1

View Answer

Answer: d [Reason:] None.

3. What is the output of this C code (if run with no options or arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         printf("%dn", argc);
  5.         return 0;
  6.     }

a) 0
b) 1
c) Depends on the platform
d) Depends on the compiler

View Answer

Answer: b [Reason:] None.

4. What is the output of this C code (run without any commandline arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         while (argc--)
  5.         printf("%sn", argv[argc]);
  6.         return 0;
  7.     }

a) Compile time error
b) Executablefilename
c) Segmentation fault
d) Undefined

View Answer

Answer: b [Reason:] None.

5. What is the output of this C code (run without any commandline arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         printf("%sn", argv[argc]);
  5.         return 0;
  6.     }

a) Segmentation fault/code crash
b) Executable file name
c) Depends on the platform
d) Depends on the compiler

View Answer

Answer: a [Reason:] None.

6. What is the output of this C code (run without any commandline arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         while (*argv++ != NULL)
  5.         printf("%sn", *argv);
  6.         return 0;
  7.     }

a) Segmentation fault/code crash
b) Executable file name
c) Depends on the platform
d) Depends on the compiler

View Answer

Answer: a [Reason:] None.

7. What is the output of this C code (run without any command line arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         while (*argv  !=  NULL)
  5.         printf("%sn", *(argv++));
  6.         return 0;
  7.     }

a) Segmentation fault/code crash
b) Executable file name
c) Depends on the platform
d) Depends on the compiler

View Answer

Answer: b [Reason:] None.

8. What is the output of this C code(run without any command line arguments)?

  1.     #include <stdio.h>
  2.     int main(int argc, char *argv[])
  3.     {
  4.         while (argv != NULL)
  5.         printf("%sn",  *(argv++));
  6.         return 0;
  7.     }

a) Segmentation fault/code crash
b) Executable file name
c) Depends on the platform
d) Depends on the compiler

View Answer

Answer: a [Reason:] None.

.woocommerce-message { background-color: #98C391 !important; }