I'm beginning in C++ so my code is probably redundant and/or excessively lengthy.

The goal: Calculate the ratio of 5-year average wins to 5-year average losses.

Progress: So far I've been able to gather the data and define "AverageWin" and "AverageLoss"

Problem: I am having difficulty working with the Euclid Algorithm to find the greatest common factor, then reduce the "AverageWin" and "AverageLoss" to simplest terms and present them in terms of a ratio (x:x).

Errors: "Variables a,b,gcd being used without being initialized."

"Integer division by zero"

I've researched as much as I could and tried to work the algorithm towards my needs but I can't seem to figure it out.

Any help would be appreciated, thank you.

#include <iostream> using namespace std; int main( ) { int year1Win, year2Win, year3Win, year4Win, year5Win; double AverageWin; cout << "Enter the number of wins for year 1: "; cin >> year1Win; cout << "Enter the number of wins for year 2: "; cin >> year2Win; cout << "Enter the number of wins for year 3: "; cin >> year3Win; cout << "Enter the number of wins for year 4: "; cin >> year4Win; cout << "Enter the number of wins for year 5: "; cin >> year5Win; AverageWin = (year1Win + year2Win + year3Win + year4Win + year5Win)/5; cout << "Five year average win for this team is: " << AverageWin; cout << "\n"; int year1Loss, year2Loss, year3Loss, year4Loss, year5Loss; double AverageLoss; cout << "Enter the number of losses for year 1: "; cin >> year1Loss; cout << "Enter the number of losses for year 2: "; cin >> year2Loss; cout << "Enter the number of losses for year 3: "; cin >> year3Loss; cout << "Enter the number of losses for year 4: "; cin >> year4Loss; cout << "Enter the number of losses for year 5: "; cin >> year5Loss; AverageLoss = (year1Loss + year2Loss + year3Loss + year4Loss + year5Loss)/5; cout << "Five year average loss for this team is: " << AverageLoss; cout << "\n"; int n, d, gcd, a, b, smplfyWin, smplfyLoss; AverageWin=a; AverageLoss=b; while (gcd!=0) { gcd = a % b; a = b; b = gcd; } smplfyWin = (a/gcd); smplfyLoss = (b/gcd); cout << "The ratio of wins to losses is " << smplfyWin; cout << ":"<< smplfyLoss; cout << "\n"; system ("pause"); return 0;