Why the loop is not stopping ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
10th Mar 2022, 11:52 AM
Abhay mishra
Abhay mishra - avatar
3 Answers
0
Initialize variable i outside the loop, not inside it
10th Mar 2022, 11:56 AM
Infinity
Infinity - avatar
0
move the i out of the loop #include<stdio.h> int main() { int i ; char d ; i = 1 ; do{ printf("Have you driven car ? y/n \n") ; scanf("%c" , &d) ; if(d =='n') { continue ; } printf("You can be vicitim of that murder \n") ; i++ ; } while(i <= 3) ; return 0 ; }
10th Mar 2022, 11:56 AM
Nima
0
Thanks infinity sir and nima sir 😊
10th Mar 2022, 11:58 AM
Abhay mishra
Abhay mishra - avatar