Aleksa Stojković
Aleksa Stojković

Reputation: 11

C - program ends after a do-while loop

...

do {

   printf("A:");
   scanf(" %d", &cm);

   printf(" %d od x\n", 100*(Info20-Info10)/cm);

} while (cm != 0);

int V;

for(V = 0; V <=100; V += 8) {
printf("V: %d.\n", V);

}

...

The problem is the transition from the do-while loop to the for loop below, the exit key is 0 and after getting that input, the program ends instead of proceeding to the code below.

Upvotes: 0

Views: 178

Answers (1)

santo
santo

Reputation: 417

Because, if you insert 0, you do a division for 0.

printf(" %d od x\n", 100*(Info20-Info10)/cm);

raises an error

Upvotes: 2

Related Questions