im learning by my own how to code with C++, i got to the topic of Structures. The book has some exercises and i am atempting to complete them..

it asks for a program that would be able to add fractions..

i have somehow an idea of how it would be, but my here's my problem.

I ask for the fraction, i would like to have that fraction compared to a variable thus making it decimal, so i can perform any operation (+, -, x, /) with decimals, and if possible that most common fractions be displayed (1/2, 1/4, 1/8) but not like1/3453.

here's the code of what i been working..

__________________________________________________ __

#include <iostream>

using namespace std;

struct math //structure tag

{

float firstInteger;

};

void main()

{

float equivalent;

math fraction; //define the structure object

cout<<"Enter the first integer: ";

cin>>fraction.firstInteger;

if (fraction.firstInteger= 1/2)

equivalent=.5;

cout<<"___this is the equivalent" <<equivalent<<endl;

cout<<"Your 1st Integer is: \n["<<fraction.firstInteger<<" ]"<<endl;

//End of code

_______________________________________________

any help would be appreciated, THANK YOU!