- 1

why i keep getting the same output

why i keep getting the same output in the case even though its suppose to have different answer/output the coding: #include<stdio.h> int main() { int t, n, m, o, c=0; scanf ("%d", &t); //for how many times input will be done while (c<t) { //for how many times input will be done scanf ("%d", &n); c++;} for (int d=0; d<t; d++) { m=n/365; o=m/4; printf ("Case #%d :\n%d\n",d+1, o+1); }    }  the output: 3 1 100 1460                     // until here is input Case #1:              // from here is output 2 // the answer supposed to be 1 Case #2 : 2 // this answer also 1 Case #3 : 2 // only this that the answer is true

12th Oct 2018, 1:08 AM
Yoaraci
Yoaraci - avatar
2 Answers
+ 1
Because you read all three n values before you calculate the output, n is 1460 for all three outputs. If you want to read them all, you must have three different places to store them.
12th Oct 2018, 2:37 AM
John Wells
John Wells - avatar
0
thanks for the answer :)
12th Oct 2018, 2:46 AM
Yoaraci
Yoaraci - avatar