How long does this loop run:

for(int x=0; x=3; x++)
a) Never
b) Three times
c) Forever

Answers were Sorted based on User's Feedback



How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / pracheer gupta

what r u saying guys..
the loop will run c) forever
this is bcoz in the termination part it is actually x=3 and
not x==3.
x=3 will always evaluate to true and hence the loop is
executed infinite times.

Is This Answer Correct ?    91 Yes 11 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / guest

Forever

Is This Answer Correct ?    55 Yes 9 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / manju

The correct and verified answer is the loop runs forever

the answer is c. it is so becoz in condition part we are
giving i=3 and not i==3.


so it executes infinite times.

Is This Answer Correct ?    32 Yes 3 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / eric

The loop will run forever.
K.premalatha is the foolest lady I have ever met.

Is This Answer Correct ?    17 Yes 3 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / sentrix

Forever.

Is This Answer Correct ?    17 Yes 4 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / john

the loop runs forever guys....
have you tried this? without trying u r giving the random answers?
Sentrix, Eric, Manju,Pracheer Gupta are right...
other guys please try it....

Is This Answer Correct ?    17 Yes 4 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer /

#include<stdio.h>
main()
{
for(int x=0; x=3; x++)
printf("Forever.....");
}

Is This Answer Correct ?    14 Yes 2 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / divya

hai john I tried this in online compiler but it shows some errors....didnt give exact ans...Is there any other ways to conform this answer.

Is This Answer Correct ?    2 Yes 0 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / madhupathania

forever

Is This Answer Correct ?    1 Yes 0 No

How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever ..

Answer / awaneesh dubey

Never . It will show compile time error . boolean required
at the terminationa condition not int . i.e. it should be
for(int x=0; x==3; x++) not for(int x=0; x=3; x++) .
x=3 will cause compilation error. So answer is never .

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C++ General Interview Questions

On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?

0 Answers  


What do you mean by static variables?

0 Answers  


How do you declare A pointer to function which receives an int pointer and returns a float pointer

0 Answers  


How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?

0 Answers  


What are the manipulators in c++?

0 Answers  






I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?

0 Answers  


In c++, what is the difference between method overloading and method overriding?

0 Answers  


In which memory a class gets stored(in heap /in stack)? And why??

2 Answers  


Reverse the Linked List. Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL

0 Answers  


Can you help me with this one? Make a program that when a user inputed a Product Name, it will display its price, and when the user inputed the quantity of the inputed product, it will show its total price. The output must be like this: Product Name: Price: Quantity: Total Price: ..this is the list of products to be inputed: Cellphone - 1500 Washing Machine - 5200 Television - 6000 Refrigirator - 8000 Oven - 2000 Computer - 11000 thanks..:D

1 Answers  


What is the difference between while and do while loop?

0 Answers  


What are function prototypes?

0 Answers  


Categories