0

How can you limit a number of trials in c language?

C language

25th Oct 2020, 5:52 AM
Arrr
6 Answers
+ 2
https://code.sololearn.com/c2gyGa5OTu5n/?ref=app How about this Davide. I already program a multiple trials and I want to limit a 3 trials only.
26th Oct 2020, 7:16 AM
Arrr
+ 1
Okay thanks
26th Oct 2020, 9:23 AM
Arrr
0
Your question is too general. In general you do it with an if() statement, with a loop or with both.
25th Oct 2020, 11:04 AM
Davide
Davide - avatar
0
Arrr fix these things first: Line 38: is getchar not getche Line 38: remove the } bracket at the end of the line In general: declare "int i;" only once at the top of the code and then write just "i = 0" inside the for loops The if() at line 31: since it is always executed except for the first time, your program would be smoother if you print the first number right before the for() and then use the loop to print "+" and another number. So the program don't have to check an if() condition for every lap. Note that in this case you need to enter the loop with "i = 1" because you already printed the first. Now to limit the tries declare "int tries = 1;" at the top. If the user chose "Y" increment "tries". Then in the while add "&& tries < 4" and that's it.
26th Oct 2020, 8:35 AM
Davide
Davide - avatar
0
https://code.sololearn.com/c2gyGa5OTu5n/?ref=app Thank you for that but still, it doesn't work Davide
26th Oct 2020, 9:08 AM
Arrr
0
Arrr are you kidding me? Of course it doesn't work. You deleted the do{}, are missing semicolons and have done strange things with commas. I already told you everything you needed. Now with the help of the errors from the compiler, do your part.
26th Oct 2020, 9:22 AM
Davide
Davide - avatar