related to test cases | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

related to test cases

when test case is given, how to print anwsers of all test cases together at the end of the program in output? #include <stdio.h> #include <conio.h> int main() { int t,i; scanf("%d",&t); int a,b,R[t]; while(t!=0) { scanf("%d %d",&a,&b); int r=a%b; R[t]=r; t--; } for(i=0;i<t;i++) { printf("%d\n",R[i]); } return 0; }

29th Jan 2021, 8:33 AM
Mahima Desani
4 Answers
+ 2
Mahima Desani No need to print answer of all test cases. You just have to write a logic which will print output whatever we provide input.
29th Jan 2021, 8:36 AM
A͢J
A͢J - avatar
+ 2
Ok ... thanks
29th Jan 2021, 9:07 AM
Mahima Desani
0
But I want output after all input are taken from user for example for find remainder test case =2 1 2 40 15 so, I want out of both test case after insertion of both input. output : 1 10 like this...
29th Jan 2021, 8:38 AM
Mahima Desani
0
Your code has two problems: conio.h is unavailable and not needed anyway it seems You have to keep t for output loop to work, but you are decreasing it to 0 before. Use i in first loop instead #include <stdio.h> int main() { int t,i; scanf("%d",&t); int a,b,R[t]; for(i=0;i<t;i++) { scanf("%d %d",&a,&b); int r=a%b; R[i]=r; } for(i=0;i<t;i++) { printf("%d\n",R[i]); } return 0; }
29th Jan 2021, 8:57 AM
Benjamin Jürgens
Benjamin Jürgens - avatar