Cisco Systems Interview Question for Software Engineer / Developers


Country: United States




Comment hidden because of low score. Click to expand.
6
of 8 vote

x = x++ + ++y; (1)
y = ++x + ++y; (2)

In (1) this is the following operations to be done.
i) ++y
ii) x = x+y
iii) x ++

In (2) this is the following operations to be done.
i) x ++
ii) y++
iii) y = x + y

- Psycho May 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

i have a doubt .

the precedence of increment operator is higer than +,*,/ ,then before performing addition,The postfix and prefix operation is performed then then arithmetic operation.
in both cases i think the operations to be done are
i)++x
ii)y++
iii)y=x+y

- Rishabh June 12, 2015 | Flag
Comment hidden because of low score. Click to expand.
3
of 3 vote

What I can tell from the C standard, that in x = x++ + ... the value of x is getting modified twice within one sequence point. So it is Undefined Behaviour and the answer would vart depending upon the implementation of the compiler.

- Mukesh May 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

when x = 1, y = 1, we got x = 5, y = 8 after that

- milo May 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

c++

- milo May 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hindi

- Anon August 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

What language?

- Anonymous May 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hindi

- Anon August 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Undefined, will depend on compiler to compiler

- shani May 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

x=5 and y=8

- ric May 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

5,8 with following compiler.
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

- kiran May 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Its UB (Undefined-Bahvior). value of x is being modified without any sequence-point in between. There is no way you can be sure of the value of x.

- arnuld May 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I wrote the code and tested no matter what you do in both the cases x & y will be incremented first as they are closely bind to "++" and after they are incremented then only they are added, refer wiki for operator precedence.

if x = y = 0 initially, both cases will have answer 2,
if x = 1, y =2 then both cases will have answer 5.

- Anonymous May 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<math.h>
#include<conio.h>
int main()
{
    int x=0,y=0,z;
    z = x++ + ++y;
     printf("%d   %d  %d  \n",x,y,z);x=z;
    y = ++x + ++y;
    printf("%d   %d   \n",x,y);
    getch();
    return(0);
}

output 1 1 1
2 4

- sunil August 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Sunil:
You have written the wrong expression than the one asked in question. The LHS of the assignment operator in 1st line is 'x' and not 'z'. And that is the key thing which makes this Q tricky!

- Aamo September 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

x will become x+y+3 & y will be x+2y+5

#include<stdio.h>

int main()
{
    int x=5,y=15;
    x= x++ + ++y;
    y = ++x + ++y;
    printf("%d %d",x,y);
    return 0;
}

Output: 23 40

- Nishant Kumar September 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

don't know the answer

- prachi October 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I get the output 22 39 for that same code.

- Anonymous January 13, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Answer is 22,40

- Anonymous March 27, 2019 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

output shown by my computer is 22 and 39

- Anonymous August 02, 2019 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
main()
{
    int x=0,y=0;
    x= x++ + ++y;
    printf("x: %d\ty:%d\n", x,y);
    y= ++x+ ++y;
    printf("x: %d\ty:%d\n", x,y);
}

Output:
x: 2 y:1
x: 3 y:5

- slimster November 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

. main ()
{
int x=5;
x=x----1;
printf ("%d", x);
}
Output?

- Anonymous May 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int x=2;y=3;
x=x++ +y++;
y=++x +++y;

- Manisha jain May 28, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

x=7
y=12

- Deep February 17, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

x+(y--)-x+(x++)-(y--)

- raj September 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h> int main(){
int i,x;
int i=printf("c" "++"); for(x=0;x<=i;x++){ printf("%x ",x);
}
return 0;
}

- Anonymous October 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

x=(x+1)+y;

y=x+y;

bluej pattern

- Shubham October 25, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
int y = 2;
y = (y++)/(y++);
printf("%d", y++);
}

- Anonymous March 26, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Cisco gives hike once in 2-3 years.

New-Joinees only get hike after 2-3 years, so take 100% hike at the time of joining .. . otherwise don't cry after joining. :)

- Simple April 25, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int x = 1;
int y = x++;
int z = ++y;
y = z++;
z = ++z;
what will be the value of z?

- Anonymous August 30, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Void main()
{
Int x=5;
x=x----1;
Of("℅d",x);
}
Will the value of x be 6 or its an error??

- manisha November 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

same problem comes with:
int x=2,y;
void main()
{
y=++x + ++x + x++; //gives output 12
y=++x + ++x + x++; //gives output 17

}


kindly explain

- mahi March 10, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

int x=2,y;
void main()
{
y=++x + ++x + x++; //gives output 12
y=++x + ++x + x++; //gives output 17

}
it gives 21 not 17

- Anonymous June 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

int x=2,y;
void main()
{
y=++x + ++x + x++; //gives output 12
y=++x + ++x + x++; //gives output 17

}
gives u 21 not 17

- amkit bansal June 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

main()

{ int x, y, flag=0;

for(x=0; x<3; x++)

for(y=x+1; y<5; y++)

flag += x*y;

}

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

#include<stdio.h>

int main ()
{
int x=2, y=4;
int z=x+x+x+x+(x++);
printf("x=%d \n y=%d \n z=%d",x,y,z);
return 0;
}

OUTPUT:
x=3
y=4
z=10

#include<stdio.h>

int main ()
{
int x=2, y=4;
int z=(x++)+x+x+x+x;
printf("x=%d \n y=%d \n z=%d",x,y,z);
return 0;
}

OUTPUT:
x=3
y=4
z=14

Please someone explain the code. Why the output are different to each other?

- Shihab Ahmed November 10, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

int main ()
{
    int x=2, y=4;
    int z=x+x+x+x+(x++);
    printf("x=%d \n y=%d \n z=%d",x,y,z);
    return 0;
}

OUTPUT:
      x=3
      y=4
      z=10

#include<stdio.h>

int main ()
{
    int x=2, y=4;
    int z=(x++)+x+x+x+x;
    printf("x=%d \n y=%d \n z=%d",x,y,z);
    return 0;
}

OUTPUT: 
       x=3
       y=4
       z=14

Please someone explain the code. Why the output are different to each other?

- Shihab Ahmed November 10, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

int main ()
{
    int x=2, y=4;
    int z=x+x+x+x+(x++);
    printf("x=%d \n y=%d \n z=%d",x,y,z);
    return 0;
}

OUTPUT:
x=3
y=4
z=10

#include<stdio.h>

int main ()
{
    int x=2, y=4;
    int z=(x++)+x+x+x+x;
    printf("x=%d \n y=%d \n z=%d",x,y,z);
    return 0;
}

OUTPUT:
x=3
y=4
z=14

Please someone explain the following code above. Why the output of z are different to each oher?

- shihabahmed16 November 10, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how to declare a variable in a sub Function as "a=b" on c programming ?

what will be the syntax of it?

- shihabahmed16 November 12, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

x=20 y=15 z=22

x+=2;
y=x;
y+=10;
z–=3;
y++;
x––;
z++;
y*=2;
x/=1;
z–=7;

- Tekin January 07, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

x=1;
z=x++ + x;

- Anonymous July 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if x=3,y=4 then value of=++x+ - - y+x - - +y - -

- Sakshi August 20, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I have a doubt
if x=3,y=4 then value of=++x+ - - y+x - - +y - -

- Sakshi August 20, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int x, y = 1, z;
if (x = z = y);
x = 3;
while (y < 4) {
x += ++y;
}

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

23 39

- Amol September 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how does this output come??? can ou provide explanation
int y=5,x;
x=(++y)+(++y);
cout<<x;
output is 14

- manasa November 21, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Int x,y=0;
For(x=1;x<=5;++x)
y=x++;
--y;
What will be the value of x and y?

- Anonymous December 28, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if intial value of x and y was a and b respectively,then
x=a+b+2 and y=a+2*b+4

- arpit gupta March 02, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If P=5; find d=++p + 5

- Anonymous March 02, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

5

- ramya July 02, 2021 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Find value of x and y


{
int x,y;
x=3,y=1;
if(x--)
y=x+2;
if(--x)
y= --x;
if(--x)
y=x--;
}

- mohit September 18, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sala

- Tera baap October 10, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

j= --k+2k+(l=k,l++)
the value of k is 20 initially

- ambarin November 16, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what is the value of j=--k+2k+(l=k,l++)

- Ambarin Nishat Ali November 16, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

x=x×x++×++x+--x-x++×2
Please send the value

- Anonymous December 29, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if x=5, y=4, c=8
g=c-y ,D=c/y+5 what is the solution of this question

- atta khan January 09, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

d=2;Y=++d*++d*(d++*d++);

- Bunny July 24, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

d=2;Y=++d*++d*(d++*d++);

- Bunny July 24, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

d=2;Y=++d*++d*(d++*d++);

- Bunny July 24, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
d=2;Y=++d*++d*(d++*d++);
}

- Bunny July 24, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

d=2;Y=++d*++d*(d++*d++);

- Bunny July 24, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what will be the output ?
x=10;
x=+x++;

- ilakkiya.k1007 August 24, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int a=0,x;
x = ++a * --a;
cout<<++a<<" "<<a++<<" "<<x;

output?? and how??

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

Y+=++Y+Y- - + - -8

- Rohan lakra January 10, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Y+=++Y+Y--+--Y
Associativity (Right to Left)
Where Y=9->then Y=8 then Y=7
Y+=26
Y=Y+26 (where Y=7)
Y=33

- Dhanya January 29, 2019 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

PSVM(string args[ ])
Int x=6
x=++×*++×%4
System. out. println(x)

- Anonymous February 21, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
int main()
{
int i=0;
printf("%d %d %d %d", i,i++,++i,i--);
return 0;
}

Output :- 1,0,1,0
Explanation?

- Anonymous May 24, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int i=0;
printf("%d %d %d %d", i,i++,++i,i--);

output:- 1,0,1,0
Explamation required.

- Anonymous May 24, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Int x=2;
Printf("\n%d",++x % x++);
What should be the output??

- Pinki June 10, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A=--A +B++ + ++B + --B * C++ (A=12 B=13 C= 11)

- Sejal Patel August 03, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<conio.h>
void main()
{
int x=5,y;
y=(++x)+(--x);
printf("%d",y);
}

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

#include<stdio.h>
#include<conio.h>
void main()
{
int x=5,y;
y=(++x)+(--x);
printf("%d",y);
}
What will be the answer of this???

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

++8 + ++7* ++0

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

Using which procedure the following two expressions are solved;

#include<stdio.h>
#include<math.h>
void main()
{
	int z=10,a,b;
	a=++z + ++z + ++z + z++;
	b=z++ + ++z + ++z + z++;
	printf("%d\n",a); // i am getting a=49
	printf("%d\n",b); // b= 47
	printf("%d\n",z); // z=14

getch();
}

- rahul rao January 20, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

y=++x+y+++x+++++y
x=++y+++y+x+++x++

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

y=++x+y+++x+++++y, x=++y+++y+x+++x++

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

int x=20,y=35;
x=y++ +x++;
y=++y + ++x;
Printf("%d%d",x,y);

- Anonymous July 12, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Int a= 25 int b=5

- Anonymous July 23, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

What I can tell from the C standard, that in x = x++ + ... the value of x is getting modified twice within one sequence point. So it is Undefined Behaviour and the answer would vart depending upon the implementation of the compiler.

- Mukesh May 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

x+(y--)-x+(x++)-(y--) if x=y=2

- raj September 24, 2013 | 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