Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


What will happen when the following code is run:
int x;
while(x<100)
{
cout<<x;
x++;
}




1) The computer will output "0123...99"


2) The computer will output "0123...100"


3) The output is undefined

Answers were Sorted based on User's Feedback



What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; ..

Answer / nk

Output is undefined because initially variable 'x' is not
initialized and may contain some garbage value.

However if we initialize 'x' to 0 then choice#1 is correct.

Is This Answer Correct ?    13 Yes 0 No

What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; ..

Answer / d n gavade

The Answer is 3)The Output is undefined because x is not
initialised and its datatype is auto int so that its inital
value will be garbage.

Is This Answer Correct ?    3 Yes 0 No

What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; ..

Answer / deepanker aggarwal

the answer is 3 because x is not initialised and it may
contain any garbage value

Is This Answer Correct ?    1 Yes 0 No

What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; ..

Answer / rakesh

the output is undefined
because c++ do not implicitly initialised the varible. it
gives garbage value for uninitialized variables

Is This Answer Correct ?    1 Yes 0 No

What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; ..

Answer / ibrazileasum

The initial value of x is not defined to '0' hence the complier will not start from 0 as initial value. This is a garbage error to the compiler

Is This Answer Correct ?    0 Yes 0 No

What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; ..

Answer / aravind

In most of the compilers now all declared variables are
usually initialised with 0. So in most compilers result
would be #1. But in some cases the garbage values may creep
up.

Is This Answer Correct ?    0 Yes 1 No

What will happen when the following code is run: int x; while(x<100) { cout<<x; x++; ..

Answer / sanish joseph

ans s absolutely right..

Is This Answer Correct ?    1 Yes 3 No

Post New Answer



More OOPS Interview Questions

What are the benefits of oop?

0 Answers  


What is encapsulation and abstraction? How are they implemented in C++?

0 Answers   Agilent, ZS Associates,


Have you ever used threads?

3 Answers   Adobe, IBM,


what type of questions

0 Answers   IBM,


i had specified the access specifier for abstarct class member like (pure virtual function) as private.But it can be accessed by the derived class.How the private member of one class is accessed by other class.if any body face this problem and found the solution plz reply to me.

1 Answers   Syntel,






What do you mean by binding of data and functions?

3 Answers  


just right the logic of it 1--> If few people are electing then every time ur candidate should win 2--> arrange books in box, if box carry weight == books weight then take another box..... find the no of box required.

0 Answers  


Can we have a private constructor ?

12 Answers   HSBC, Ness Technologies, TCS, Wipro,


Difference between realloc() and free?

9 Answers   HP,


Who invented oop?

0 Answers  


why oops need in programming

7 Answers   TCS,


what is the new version of oops

0 Answers   Ignou,






Categories