Student Interview Question for Students


Country: India




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

Because the lifetime of variable x is within the scope of main and the code where x is incremented is within a sub block inside main(). So whatever is done within the sub block has impact on the main().

- Bad coder February 07, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

so the sub block does effect the code.?

- Divyanshu Vishal February 07, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

yes, sub block can access its parent scope.

- mallaudinqazi February 07, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

because you use "++" operator, which modifies "x" variable.

- zr.roman February 07, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

X++ is postincrement operator , this mean X is not incremented immeadiately when it is X++ is executed, that's why y is assigned to value 10, not 11, but X new value will be available in the next reference of X (printf("%d",x))

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

starting x=10
the operator x++ means x=x+1 therefore x=11
y=11

- dk90833 February 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Here the statement is y=x++, ie value of x will be assigned to y as 10 and the value of x is incremented(post-increment)

- shameerariff February 12, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

When the variable x is initialized it is assigned with value 10,when it comes to the statement y=x++, the value of x 10 is assigned to y and x will undergo post-increment so the value of s will become 11.

- shameerariff February 12, 2016 | 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