C++ Questions

Q:

What is meaning of following declaration?
int(*p[5])();

A) p is pointer to function. B) p is array of pointer to function.
C) p is pointer to such function which return type is array. D) p is pointer to array of function.
 
Answer & Explanation Answer: B) p is array of pointer to function.

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++ - Technology

14 28846
Q:

Which of the following is a properly defined structure?

A) struct {int a;} B) struct a_struct {int a;}
C) struct a_struct int a; D) struct a_struct {int a;};
 
Answer & Explanation Answer: D) struct a_struct {int a;};

Explanation:

The a_struct is declared as structure name and its data element is a.

Report Error

View Answer Report Error Discuss

Filed Under: C++ - Technology

11 23093
Q:

What is function prototyping? What are its advantages?

Answer

Function prototyping is a function declaration statement that tells the compiler about the return type of the function and the number as well as type of arguments required by the function at the time of calling it.


Syntax:


return_type function_name( type1 arg1, type 2 arg2, ... );


 


Advantages of function prototype :


- It helps the compiler in determining whether a function is called correctly or not. Each time when a function is called, its calling statement is compared with its prototype. In case of any mismatch, compiler reports an error.


- A function must be defined before calling it. But prototyping allows a function to be called before defining it.

Report Error

View answer Workspace Report Error Discuss

Subject: C++ - Technology

34 21322
Q:

Which of the following gives the memory address of the first element in array?

A) array[0]; B) array[1];
C) array(2); D) array;
 
Answer & Explanation Answer: D) array;

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++ - Technology

20 20798
Q:

Which is more effective while calling the functions?

A) call by value B) call by reference
C) call by pointer D) none
 
Answer & Explanation Answer: B) call by reference

Explanation:

In the call by reference, it will just copy the address of the variable to access it, so it will reduce the memory in accessing it.

Report Error

View Answer Report Error Discuss

Filed Under: C++ - Technology

15 20724
Q:

What is the default return type of a function ?

A) int B) void
C) float D) char
 
Answer & Explanation Answer: B) void

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++ - Technology

19 16402
Q:

What is the difference between stack and array?

Answer

Stack:


 - Stack is a ordered collection of items


 - Stack is a dynamic object whose size is constantly changing as items are pushed and popped .


 - Stack may contain different data types


Array:


- Array is an ordered collection of items


- Array is a static object i.e. no of item is fixed and is assigned by the declaration of the array


- It contains same data types.

Report Error

View answer Workspace Report Error Discuss

Subject: C++ - Technology Exam Prep: GATE

24 15014
Q:

In tree construction which is the suitable efficient data structure?

A) Array B) Linked list
C) Stack D) Queue
 
Answer & Explanation Answer: B) Linked list

Explanation:

Linked list is the efficient datastructure in tree construction

Report Error

View Answer Report Error Discuss

Filed Under: C++ - Technology

5 14931