Archive for the ‘C++’ Category

C interview questions part1

C interview questions part1

What will print out?

char *p1=“name”;
char *p2;
memset (p2, 0, 20);
while(*p2++ = *p1++);


Answer:empty string.

What will be printed as the result of the operation below:

int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;

Answer : 5794

What will be printed as the result of the operation below:

int x=5;
printf(“%d,%d,%dn”,x,x< <2,x>>2);

Answer: 5,20,1

What will be printed as the result of the operation below:

#define swap(a,b) a=a+b;b=a-b;a=a-b;

void main()
int x=5, y=10;
swap (x,y);
printf(“%d %dn”,x,y);
printf(“%d %dn”,x,y);

int swap2(int a, int b)
int temp;
return 0;

Answer: 10, 5 Read more…

Categories: C++ Tags:

Good C++ Interview questions

Good C++ Interview questions

TSome good C++ questions to ask a job applicant.

How do you decide which integer type to use?

What should the 64-bit integer type on new, 64-bit machines be?

What’s the best way to declare and define global variables?

What does extern mean in a function declaration?

What’s the auto keyword good for?

I can’t seem to define a linked list node which contains a pointer to itself.

How do I declare an array of N pointers to functions returning pointers to functions returning pointers
to characters?

ow can I declare a function that returns a pointer to a function of its own type?

My compiler is complaining about an invalid redeclaration of a function, but I only define it once and call it once. What’s happening?

What can I safely assume about the initial values of variables which are not explicitly initialized?

Why can’t I initialize a local array with a string?

What is the difference between char a[] = “string”; and char *p = “string”; ?

How do I initialize a pointer to a function.

Categories: C++ Tags:

Intel interview questions

Intel interview questions

The following questions are used for screening the candidates during the first interview. The questions apply mostly to fresh college grads pursuing an engineering career at Intel.
Have you studied buses? What types?

Have you studied pipelining? List the 5 stages of a 5 stage pipeline. Assuming 1 clock per stage, what is the latency of an instruction in a 5 stage machine? What is the throughput of this machine ?

How many bit combinations are there in a byte?

For a single computer processor computer system, what is the purpose of a processor cache and describe its operation?

Explain the operation considering a two processor computer system with a cache for each processor.

What are the main issues associated with multiprocessor caches and how might you solve them?

Explain the difference between write through and write back cache.

Are you familiar with the term MESI?

Are you familiar with the term snooping?

Describe a finite state machine that will detect three consecutive coin tosses (of one coin) that results in heads.

In what cases do you need to double clock a signal before presenting it to a synchronous state machine?

You have a driver that drives a long signal & connects to an input device. At the input device there is either overshoot, undershoot or signal threshold violations, what can be done to correct this problem?

What are the total number of lines written by you in C/C++? What is the most complicated/valuable program written in C/C++?

What compiler was used?

What is the difference between = and == in C?

Are you familiar with VHDL and/or Verilog?

What types of CMOS memories have you designed? What were their size? Speed?

What work have you done on full chip Clock and Power distribution? What process technology and budgets were used?

What types of I/O have you designed? What were their size? Speed? Configuration? Voltage requirements?

Process technology? What package was used and how did you model the package/system? What parasitic effects were considered?

What types of high speed CMOS circuits have you designed?

What transistor level design tools are you proficient with? What types of designs were they used on?

What products have you designed which have entered high volume production?

What was your role in the silicon evaluation/product ramp? What tools did you use?

If not into production, how far did you follow the design and why did not you see it into production?

Categories: C++ Tags:

C++ gamedev interview questions

C++ gamedev interview questions

This set of questions came from a prominent gaming company. As you can see, the answers are not given (the interviews are typically conducted by senior developers), but there’s a set of notes with common mistakes to avoid.

Explain which of the following declarations will compile and what will be constant – a pointer or the value pointed at:

const char *
char const *
char * const

Note: Ask the candidate whether the first declaration is pointing to a string or a single character. Both explanations are correct, but if he says that it’s a single character pointer, ask why a whole string is initialized as char* in C++. If he says this is a string declaration, ask him to declare a pointer to a single character. Competent candidates should not have problems pointing out why const char* can be both a character and a string declaration, incompetent ones will come up with invalid reasons.

You’re given a simple code for the class BankCustomer. Write the following functions:
Copy constructor

= operator overload
== operator overload
+ operator overload (customers’ balances should be added up, as an example of joint account between husband and wife)

Note:Anyone confusing assignment and equality operators should be dismissed from the interview. The applicant might make a mistake of passing by value, not by reference. The candidate might also want to return a pointer, not a new object, from the addition operator. Slightly hint that you’d like the value to be changed outside the function, too, in the first case. Ask him whether the statement customer3 = customer1 + customer2 would work in the second case. Read more…

Categories: C++ Tags:

Embedded systems interview questions

Embedded systems interview questions

Can structures be passed to the functions by value?

Why cannot arrays be passed by values to functions?

Advantages and disadvantages of using macro and inline functions?

What happens when recursion functions are declared inline?

Scope of static variables?

Difference between object oriented and object based languages?

Multiple inheritance – objects contain howmany multiply inherited ancestor?

What are the 4 different types of inheritance relationship?

How would you find out the no of instance of a class?

Is java a pure object oriented language? Why?

Order of constructor and destructor call in case of multiple inheritance?

Can u have inline virtual functions in a class? Read more…

Categories: C++ Tags:

Software tester interview questions

Software tester interview questions

The questions were asked by Lucent Technologies for Software Tester (in some companies SQA – Software Quality Assurance) position.

What programming language are you using?

What C++ libraries are you proficient with?

Which argorithm do you like the most? Why?

How do you debug SSH?

What is the QA process?

How do you train another QA engineer?

What bug tracking tools you have used? Have you used any free tools?

How do you start your QA if there are no system requirements?

Have you used MSVC? What do you think of it?

There are 3 lights (in one room) and 3 swtiches (in another room), one for each, if you only enter into the light room once. How can you find out which switch corresponds to which light?

What is your weakness?

Why do you think you are suited for this job?

If there is a day, when you find yourself not fitting in our team, what will you do?

What makes you think you are qualified for this job?

Do you like music? Which composers are your favourite?

What kind of PC games you like most? Why?

Are you familiar with collboration tools? Which communication method do you prefer for talk, email and chat?

When will you be available to start work?

What security tools have you used?

Tell me about yourself.

Tell me about your experience with this type of work

What do you like and dislike about our company?

Why do you want to work for us?

What should we hire you? What can you do for us? What can you do that others can not?

What is the job’s most attractive and least attractive factor?

What do you look for in a job?

Please give me your definition of software test engineer.

How long whould it take you to make a meaningful contribution to our firm?

How long would you stay with us?

Are you thinking of going back to school or college?

What kind of programs/machines or equipment have you worked with?

You may be overqualified for this position we have to offer.

Give me an example of a project you handled from start to finish.

What was your last employer’s opinion of you?

Can you work under pressure, deadline etc?

Do you have any questions?

What is it you liked and disliked about your last job?

Categories: C++ Tags:

C interview questions

C interview questions

A frequent reader of this site sent this in. No answers, but a nice set of questions. Consider getting Kernighan and Ritchie title if you find many things puzzling here.

What does static variable mean?

What is a pointer?

What is a structure?

What are the differences between structures and arrays?

In header files whether functions are declared or defined?

What are the differences between malloc() and calloc()?

What are macros? What are the advantages and disadvantages?

Difference between pass by reference and pass by value?

What is static identifier?

Where are the auto variables stored?

Where does global, static, local, register variables, free memory and C Program instructions get stored?

Difference between arrays and linked list?

What are enumerations?

Describe about storage allocation and scope of global, extern, static, local and register variables?

What are register variables? What are the advantage of using register variables?

What is the use of typedef?

Can we specify variable field width in a scanf() format string? If possible how?

Out of fgets() and gets() which function is safe to use and why?

Difference between strdup and strcpy?

What is recursion?

Differentiate between a for loop and a while loop? What are it uses?

What are the different storage classes in C?

Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?

What is difference between Structure and Unions?

What the advantages of using Unions?

What are the advantages of using pointers in a program?

What is the difference between Strings and Arrays?

In a header file whether functions are declared or defined?

What is a far pointer? where we use it?

How will you declare an array of three function pointers where each function receives two ints and

returns a float?

What is a NULL Pointer? Whether it is same as an uninitialized pointer?

What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?

What does the error ‘Null Pointer Assignment’ mean and what causes this error?

What is near, far and huge pointers? How many bytes are occupied by them?

How would you obtain segment and offset addresses from a far address of a memory location?

Are the expressions arr and *arr same for an array of integers?

Does mentioning the array name gives the base address in all the contexts?

Explain one method to process an entire string as one unit?

What is the similarity between a Structure, Union and enumeration?

Can a Structure contain a Pointer to itself?

How can we check whether the contents of two structure variables are same or not?

How are Structure passing and returning implemented by the complier?

How can we read/write Structures from/to data files?

What is the difference between an enumeration and a set of pre-processor # defines?

What do the ‘c’ and ‘v’ in argc and argv stand for?

Are the variables argc and argv are local to main?

What is the maximum combined length of command line arguments including the space between adjacent arguments?

If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?

Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

What are bit fields? What is the use of bit fields in a Structure declaration?

To which numbering system can the binary number 1101100100111100 be easily converted to?

Which bit wise operator is suitable for checking whether a particular bit is on or off?

Which bit wise operator is suitable for turning off a particular bit in a number?

Which bit wise operator is suitable for putting on a particular bit in a number?

Which bit wise operator is suitable for checking whether a particular bit is on or off?

Which one is equivalent to multiplying by 2?

Left shifting a number by 1
Left shifting an unsigned int or char by 1?

Write a program to compare two strings without using the strcmp() function.

Write a program to concatenate two strings.

Write a program to interchange 2 variables without using the third one.

Write programs for String Reversal. The same for Palindrome check.

Write a program to find the Factorial of a number.

Write a program to generate the Fibonacci Series?

Write a program which employs Recursion?

Write a program which uses command line arguments.

Write a program which uses functions like strcmp(), strcpy(), etc.

What are the advantages of using typedef in a program?

How would you dynamically allocate a one-dimensional and two-dimensional array of integers?

How can you increase the size of a dynamically allocated array?

How can you increase the size of a statically allocated array?

When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

Which function should be used to free the memory allocated by calloc()?

How much maximum can you allocate in a single call to malloc()?

Can you dynamically allocate arrays in expanded memory?

What is object file? How can you access object file?

Which header file should you include if you are to develop a function which can accept variable number of arguments?

Can you write a function similar to printf()?

How can a called function determine the number of arguments that have been passed to it?

Can there be at least some solution to determine the number of arguments passed to a variable argument list function?

How do you declare the following:

An array of three pointers to chars
An array of three char pointers
A pointer to array of three chars
A pointer to function which receives an int pointer and returns a float pointer
A pointer to a function which receives nothing and returns nothing

What do the functions atoi(), itoa() and gcvt() do?

Does there exist any other function which can be used to convert an integer or a float to a string?

How would you use qsort() function to sort an array of structures?

How would you use qsort() function to sort the name stored in an array of pointers to string?

How would you use bsearch() function to search a name stored in array of pointers to string?

How would you use the functions sin(), pow(), sqrt()?

How would you use the functions memcpy(), memset(), memmove()?

How would you use the functions fseek(), freed(), fwrite() and ftell()?

How would you obtain the current time and difference between two times?

How would you use the functions randomize() and random()?

How would you implement a substr() function that extracts a sub string from a given string?

What is the difference between the functions rand(), random(), srand() and randomize()?

What is the difference between the functions memmove() and memcpy()?

How do you print a string on the printer?

Can you use the function fprintf() to display the output on the screen?

Gautam Pagedar adds this question: What is a linklist and why do we use it when we have arrays? – I feel the correct answer should be linklist is used in cases where you don’t know the memory required to store a data structure and need to allocate is dynamically on demand.

How do you detect a loop in linked list?

Sunil asks: What is the difference between main() in C and main() in C++?

ajz at his interviews asks what will be printed out when the following code is executed:


Categories: C++ Tags:

C++ code examples for job interviews

C++ code examples for job interviews

Q: Write a short code using C++ to print out all odd number from 1 to 100 using a for loop(Asked by people)

for( unsigned int i = 1; i < = 100; i++ )
if( i & 0x00000001 )
cout << i<<",";

ISO layers and what layer is the IP operated from?( Asked by Cisco system people)

cation, Presentation, Session, Transport, Network, Data link and Physical. The IP is operated in the Network layer.

3.Q: Write a program that ask for user input from 5 to 9 then calculate the average( Asked by Cisco system people) main()
int MAX=4;
int total =0;
int average=0;
int numb;
cout< <"Please enter your input from 5 to 9";
if((numb <5)&&(numb>9))
cout< <“please re type your input”;
for(i=0;i<=MAX; i++)
total = total + numb;
average= total /MAX;
cout<<“The average number is”<

return 0;

4.Q: Can you be bale to identify between Straight- through and Cross- over cable wiring? and in what case do you use Straight- through and Cross-over? (Asked by Cisco system people)

A. Straight-through is type of wiring that is one to to one connection Cross- over is type of wiring which those wires are got switched

We use Straight-through cable when we connect between NIC Adapter and Hub. Using Cross-over cable when connect between two NIC Adapters or sometime between two hubs.

5.Q: If you hear the CPU fan is running and the monitor power is still on, but you did not see any thing show up in the monitor screen. What would you do to find out what is going wrong? (Asked by WNI people)

A. I would use the ping command to check whether the machine is still alive(connect to the network) or it is dead.

Categories: C++ Tags: