Wednesday, 11 January 2017

C and C++ interview questions and answers

C and C++ interview questions and answers



When is a switch statement better than multiple if statements?

Answer: A switch statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type.

       When is a switch statement better than multiple if statements?

Answer: A switch statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type.

How we can print "Hello World" without using semicolon in c program?

Answer: if we write the printf function inside the if block structure .
e.g. : if (printf("Hello World"));

What printf library function returns?

Answer: printf functions is having int return type which is used to return number
of elements which is printed

Which header file is used to define a function in c programming which can have variable 
number of arguments?
                  Answer: stdarg.h

How we can achieve run time polymorphism in C++?

Answer: we can achieve runtime polymorphism with the use of virtual function in 
base class in C++

What is dangling pointer?

Answer: Dangling pointer is referred to that pointer which points to deallocated 
memory location

Library function which is used to convert string value into int value?

                 Answer: atoi (), the function is defined in header file is stdlib.h

 How the overriding is different than overloading?

Answer: Overriding is achieved using redefine the base class into derived class 
but overloading is achieve using two or more functions with same name and
different arguments

Explain diamond problem of inheritance?

Answer: Diamond problem is ambiguity problem of hybrid inheritance, this 
ambiguity can be resolved using virtual base class

What is significance of argc and argv in command line arguments?

Answer: argc stands for number of arguments including executable filename,
argv stands for argument vector (set of input strings)

This Is The Newest Post

3 comments

Really Good blog post.provided a helpful information.keep updating...
Digital marketing company in Chennai

Hi There,

I learnt so much in such little time about C and C++ interview questions and answers. Even a toddler could become smart reading of your amazing articles.

I'm doing a small tool. I compile the code with gcc in MingW.

One of its windows has a lot of normal controls on it (comboboxes, editboxes, textboxes, groupboxes...).
I'm trying to reduce the window flickering (when modifying the controls) by using this code:

Code:
//button click event
SetWindowRedraw(hWnd,FALSE);

//do a lot of modifications (hide/show/move/edit controls with their repaint disabled)

SetWindowRedraw(hWnd,TRUE);
//here I get the rect of the update region
RedrawWindow(hWnd, &updrect, 0, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN | RDW_UPDATENOW);

It flickers a little less, but it can be improved.
Is there a way?

I know about "double buffered", implemented in Delphi successfully but couldn't find a way in C.

I look forward to see your next updates.

Obrigado,
Preethi

Hi There,


In total awe…. So much respect and gratitude to you folks for pulling off such amazing blogs without missing any points on the C and C++ interview questions and answers. Kudos!

m trying to do a program that displays the Olympic symbols using bresenham's algorithm but I keep getting declaration syntax error in main,
By the way do you have any YouTube videos, would love to watch it. I would like to connect you on LinkedIn, great to have experts like you in my connection (In case, if you don’t have any issues).


Thanks and Regards
Bindu


EmoticonEmoticon