Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Contrast OOP and SOA. What are tenets of each?

1 Answers   Siebel Systems, Wipro,


Can we create object of interface?

0 Answers  


What is the point of polymorphism?

0 Answers  


What does oop mean in snapchat?

0 Answers  


How do you achieve runtime polymorphism?

0 Answers  


What is class in oop with example?

0 Answers  


what type of questions

0 Answers   IBM,


Can we have a private virtual method ?

8 Answers   Ness Technologies,


How do you define social class?

0 Answers  


1.what are two type of classe members called? 2.what is data hiding and data encapsulation? 3.how do you make a class member visible aouside its class? 4.what is the default visibility of a class data member? 5.what are the advantages of oop over the structured programing?

6 Answers  


What are the benefits of oop?

0 Answers  


What is difference between #define and const?

3 Answers   emc2,


Categories