runtime error

i m confused why is following code giving runtime error!!
plz help me out

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<stdio.h>

int main()
{
   int n,m,t,i,a,b,j,p,q;
   scanf("%d",&t);
   for(i=0;i<t;i++)
   {
      scanf("%d%d",&p,&q);
      a=1;b=1;
      for(j=1;j<p;j++)
      {
          a=a+b;
          b=a+b;
          printf("%d %d\n",a,b);
          n=b;m=a;
          while(n%m!=0)
          {
             n=m;
             m=n%m;
          }
          b=b/m;a=a/m;
      }
      printf("%d/%d\n",a%q,b%q);
   }
}
What is the intention of your program - are you trolling?
sorry..i forgot to specify the input and output.

input:
3
1 10
2 12
100 10000

output should be:
1/1
2/3
4301/9525
Divide by zero exception in this line, when m == 0:
while(n%m!=0)
Topic archived. No new replies allowed.