Hi guys! i am stuck in my fraction program. i hope you guys can solve it. here i have posted my code. i am trying to get for e.g. 4/2 need to get me answer like 2/1 or 2/4 show me 1/2. i hope you can help me out. i will really appreciated. thank you

void fraction(int n, int d){
int i,j;
for(i=1;i<=d;i++)
if(n%i==0)
n = n/d;
for(j=1;j<=d;j++)
if(d%j==0)
d = d/n;
cout << n << "/" << d;
}

Please press the code tags button before pasting code. So you would code simplification? The first thing you should probably do is to test whether the fraction is prime. If the test returns false, then you should check what numbers can divide into it. Use while/for loops to test. Obviously, if either the top or bottom number is one, then you won't be able to divide, so you don't need to do all the tests. Again, you should use loops to keep dividing until you get to a prime.

To reduce the fraction you could first find the greatest common denominator (factor) for the numerator and denominator. Then divide both numerator and denominator by the greatest common denominator.

To find the greatest common denominator you can search this board or the internet for commonly used protocols. One approach has been implied by SgtMe, but there are others, too.

Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...