• +91 9723535972
  • info@interviewmaterial.com

CPlusPlus Interview Questions and Answers

CPlusPlus Interview Questions and Answers

Question - 111 : - How do you find out if a linked-list has an end? (i.e. the list is not a cycle)

Answer - 111 : - You can find out by using 2 pointers. One of them goes 2 nodes each time. The second one goes at 1 nodes each time. If there is a cycle, the one that goes 2 nodes each time will eventually meet the one that goes slower. If that is the case, then you will know the linked-list is a cycle.

Question - 112 : - How can you tell what shell you are running on UNIX system?

Answer - 112 : - You can do the Echo $RANDOM. It will return a undefined variable if you are from the C-Shell, just a return prompt if you are from the Bourne shell, and a 5 digit random numbers if you are from the Korn shell. You could also do a ps -l and look for the shell with the highest PID.

Question - 113 : - What is pure virtual function?

Answer - 113 : - A class is made abstract by declaring one or more of its virtual functions to be pure. A pure virtual function is one with an initializer of = 0 in its declaration

Question - 114 : - Write a Struct Time where integer m, h, s are its members

Answer - 114 : - struct Time { int m; int h; int s; };

Question - 115 : - How do you traverse a Btree in Backward in-order?

Answer - 115 : - Process the node in the right subtree Process the root Process the node in the left subtree

Question - 116 : - What is the two main roles of Operating System?

Answer - 116 : - As a resource manager As a virtual machine

Question - 117 : - In the derived class, which data member of the base class are visible?

Answer - 117 : - In the public and protected sections.

Question - 118 : - Could you tell something about the Unix System Kernel?

Answer - 118 : - The kernel is the heart of the UNIX openrating system, it’s reponsible for controlling the computer’s resouces and scheduling user jobs so that each one gets its fair share of resources.

Question - 119 : - What are each of the standard files and what are they normally associated with?

Answer - 119 : - They are the standard input file, the standard output file and the standard error file. The first is usually associated with the keyboard, the second and third are usually associated with the terminal screen.

Question - 120 : - Detemine the code below, tell me exectly how many times is the operation sum++ performed ?

Answer - 120 : - for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j–) sum++; (99 * 100)/2 = 4950 The sum++ is performed 4950 times.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners