0
Help over cheer creator challenge. 4/5 cases right
Task Given the number of yards that your team moved forward, output either 'High Five' (for over 10), 'shh' (for <1), or a string that has a 'Ra!' for every yard that they gained. Problem: When I put an input of 1 it prints out Ra! 9 times, and I need it to only print out once. I don’t know how to fix that. My code: https://code.sololearn.com/cIOc3vIie4Q9/?ref=app
4 Respostas
+ 2
You are using loop logic wrong.
Use while(i>0) and do i-- in loop.
You are doing while(i<10) I++ it will print untill I becomes 10 and we only have to print Ra! i times
+ 1
#include <stdio.h>
int main() {
int i;
scanf("%d", &i);
if (i > 10){
printf("High Five");
}
else if (i < 1){
printf("%s", "shh");
}
else if (i<10){
while(i>0){
printf("Ra!");
i--;
}
}
return 0;
}
+ 1
i=1
while(i<10){
printf("Ra!");
i++;
}
👇
1<10 => true
"Ra!"
i++
2<10 => true
"Ra!"
i++
...
Think about what you need to do so that i corresponds to the number of repetitions.
0
Sagar Sharma ty