0

Whi does it sais that i dumped the program

Its a practice code but it doesn't work https://code.sololearn.com/cdb63PW56ehJ/?ref=app

6th Sep 2022, 1:00 PM
Costy Game
Costy Game - avatar
3 Antworten
+ 2
what its intended to do...?
6th Sep 2022, 1:11 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 1
Line 7: Notice that the loop counter <i> begins with zero for( int i = 0; i <= num && i <= num2; i++) Line 8: The `if` conditional checks whether <i> was a factor of <num>, but loop counter <i> began with zero. I'm guessing <num> % 0 here *might be* the reason for the crash. It's hard for me to describe, but perhaps it had something to do with division by zero. if( num % i == 0 ) // <i> was zero -> crash Solution: Initialize loop counter <i> by one rather than zero P.S. What's the purpose of the second condition `i <= num2`?
6th Sep 2022, 1:12 PM
Ipang
+ 1
Thanks it work this program calculates the greatest common divisor of two numbers
6th Sep 2022, 2:31 PM
Costy Game
Costy Game - avatar