+ 1

My program does not pass case 3

You are cheering on your favorite team. After each play, if your team got over 10 yards further down the field, you stand up and give your friend a high five. If they don't move forward by at least a yard you stay quiet and say 'shh', and if they move forward 10 yards or less, you say 'Ra!' for every yard that they moved forward in that play. 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. Ans: #include<stdio.h> int main() { int i,j; scanf("%d",&i); if(i<1){ printf("shh"); } else{ for(j=1;j<=i;j++){ printf("Ra!"); } } if(i>10) {printf("High Five");} return 0; }

6th Dec 2021, 3:24 AM
Leena Patil
2 ответов
+ 2
For printing you need to use format specifiers without format specifiers u can't print use %s to print strings #include <stdio.h> int main() { int yard; scanf("%d", &yard); if (yard<1) printf("%s","shh"); else if (yard>10) printf("%s","High Five"); else for (int i=0;i<yard;i++) printf("%s","Ra!"); return 0; }
6th Dec 2021, 3:32 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
Thanks
6th Dec 2021, 3:37 AM
Leena Patil