double sum = 0;
double d;
for (d = 0; d < 10; d = d + 0.1 ) 
{
              sum = sum + d;
}

The program has a syntax error because the semicolons in the for loop are in the wrong place.

The program has a syntax error because the control variable in the for loop cannot be double.

c. The program compiles but does not stop because d would always be less than 10.

d. The program compiles and runs fine.

Recommended Answers

All 7 Replies

and what is your actual question?
even if you want to find out the hard way, all you need to do is copy paste the code, compile it and run it.

Hi thanks for the replay my question is which is the right answer of the following.

a. The program has a syntax error because the semicolons in the for loop are in the wrong place.

b. The program has a syntax error because the control variable in the for loop cannot be double.

c. The program compiles but does not stop because d would always be less than 10.

d. The program compiles and runs fine.

Repeating the question just wastes everyone's time. Read stultusk's answer, then simply try the code on your nearest computer. When you have done that, if you don't understand what happened, come back here for help.

Sounds like someone is trying to get answers for their homework because they were too lazy to pay attention in class.

The program compiles but does not stop because d would always be less than 10.

... and why do you think d is always less than 10?

its a mistake..sorry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.