Javatpoint Logo
Javatpoint Logo

C Pointers Test 3


11) According to ANSI specification, how to use main() function with command-line arguments?

  1. int char main(int argc, *argv)
  2. int main (int argc, char *argv[])
  3. int main() { int char (*argv argc); }
  4. None of the above

The correct option is (b).

Explanation:

In some cases it is necessary to give command line values to the C programming for executing the particular code when the code of program is controlled from outside. This command line values are known as command line arguments. The command line arguments are handled by main() function.

Use of main() with command line argument is,

int main (int argc, char *argv[])

Here, argv[] refers to the pointer array which points to each argument passed to the program and argc is a number of argument passed.

12) What is the error in below C statement?

  1. Memory will be allocated but cannot hold an int value in the memory
  2. Improper type casting
  3. Would throw Runtime error
  4. No issue with statement

The correct option is (d).

Explanation:

In given C statement the size of int and unsigned is same. Hence, there is no problem in allocating the memory.

Therefore the given C statement has no error.

13) Choose the correct option for the below program.

  1. First printf() prints the value less than the second
  2. Second printf() prints the value less than the first
  3. Both the printf() will print the same value
  4. Error in the code

The correct option is (c).

Explanation:

Every type of pointer variable occupies the same amount of memory irrespective of any data type.

Therefore both the printf() statement will print the same value.

14) What will be the output of the below program?

  1. C++ ++
  2. C++ C++
  3. ++ ++
  4. Compile error

The correct option is (a).

Explanation:

First print statement i.e. printf("%s ", a); used for printing the value stored in pointer a. Hence the C++ is printed in output.

After a++, a points the string "++".

Hence, the second print statement i.e. printf("%s ", a); prints the ++ in output.

Therefore the combined output of the program is C++ ++.

15) In the below statement, what does the "pf" indicates?

  1. pf is a pointer
  2. pf is a function pointer
  3. pf is a pointer of function which returns int
  4. None of the above

The correct option is (c).

Explanation:

In the given statement "pf" is a pointer as well as it holds some function reference.

Therefore "pf" indicate the pointer of function which returns int.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA