Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

Output is : 1020

- Anonymous January 23, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Anonymous..ur idea is correct. ## concatenates val1 and val2.
However in this case it would throw out an error stating that "val1val2" is not found

- Musheka January 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

But why do we get this error ?

#define FUN(val1,val2) val1##val2
#define SQR(x,y) x##y

int main(int argc, char* argv[])
{
int val1=10;
int val2=20;
printf("%d\n",SQR(val1,val2));
// printf("%d\n",FUN(val1,val2));
return 0;
}

In this code the first printf works properly but the 2nd one fails. Is this because of some peculiarity in the ##operator ?

- abhimanipal January 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

none of the statements wrk

- kamal February 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

To get an output we need to define val1val2 .

- Anonymous January 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

by definition do u mean defining their types in symbolic const stmt?

- seeker7 June 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

To get an output we need to define val1val2 .

- JD January 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This will not work because val1val2 is not a defined variable
If we add this line before it will work
FUN(val1,val2)= 100;

- dagnihot March 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

O/P=1020
## concatenates the val1 and val2.

- Anonymous April 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#definr FUN(i) (i*i)
Int main()
{
Int x, y=3;
x = FUN(y+2);
Printf("%d\n", x);
return 0;
}

- Anonymous February 01, 2020 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More