Code:

#include<iostream.h>
#include<math.h>
struct fractions
{
float a,b,c,d,e,f;
};
float sum (float u,float v);
int GCD(int a, int b);
int main (void)
{
fractions f1;
cout<<"Enter Integer value of numerator of first fraction= ";
cin>>f1.a;
cout<<"Enter Integer value of dinominator of first fraction= ";
cin>>f1.b;
cout<<"Hence first fraction= "<<f1.a<<"/"<<f1.b<< endl;
cout<<"Enter Integer value of numerator of second fraction= ";
cin>>f1.d;
cout<<"Enter Integer value of dinominator of second fraction= ";
cin>>f1.e;
cout<<"Hence second fraction= "<<f1.d<<"/"<<f1.e<< endl;
f1. c = f1.a/f1.b;
f1. f = f1.d/f1.e;
float result=sum(f1.c,f1.f);
int i=result*pow(10,3);
int j=pow(10,3);
int k=GCD(i,j);
i=i/k;
j=j/k;
cout<<f1.a<<"/"<<f1.b<<" + "<<f1.d<<"/"<<f1.e<<" = "<<i<<"/"<<j<<endl;
return 0;
}
float sum (float u,float v)
{
float w;
w=u+v;
return w;
}
int GCD(int a, int b)
{
while( 1 )
{
a = a % b;
if( a == 0 )
return b;
b = b % a;
if( b == 0 )
return a;
}
}

this also add two fractions but not for all fractions. plz tell me what is the problem..........