adding fractions

why is it giving me wrong answer error though the code is working fine on my computer console?

-http://www.codechef.com/problems/ADDFRAC

#include<stdio.h>
#include<stdlib.h>
void main()
{
	char input[13];
	int *n,flag,a,b,c,s,sd,*d,i,j,size,testcase,number;
	float sum;
	number=0;
	scanf("%d",&testcase);
	while(testcase>0){
		scanf("%d",&size);	
		n=malloc(sizeof(int)*size);
		d=malloc(sizeof(int)*size);
		for(j=0;j<size;j++){
			scanf("%s",input);
			for(i=0;input[i]!='/';i++){
				number=number*10+(input[i]-'0');
			}
			n[j]=number;
			number=0;
			i++;
			for(;input[i]!='\0';i++){
				number=number*10+(input[i]-'0');
			}
			d[j]=number;

			number=0;		
		}
	
		for(i=0;i<size;i++){
			s=n[i];
			sd=d[i];
			sum=(float)s/(float)sd;			
			flag=0;
			for(j=i+1;j<size;j++){	
				if(sum < ((float)n[j]/(float)d[j])){
					s=s+n[j];
					sd=sd+d[j];
					sum=(float)s/(float)sd;
				
				}
				else{
				
					flag=1;
					break;
				}
			}
		
			a=s;
			b=sd;
			 while (a!=0) {
   				  c=a;
   				   a=b%a;
   				   b=c;
  			} 
  			s=s/b;
  			sd=sd/b;
			printf("\n%d/%d",s,sd);
		}
		printf("\n");
		 free(n);
		 free(d);
	testcase--;
	}

}
//