Multiple Functions

My program will not work. I have tried numerous times to change things but it still wont work. Can someone please help me with this program.

#include <iostream>
using namespace std;
//Float is used.
float FORLOOP();
float DOWHILELOOP();
float WHILELOOP();

int main()
{
// This program will show my name, Id # and the class period.
//Function Protoype

int choice;
int total = 0;
float a, b, c;
//Menu Chooser
//Choose the type of loop you want to use to average this program
while (choice != 4)
{
cout << "Loops\n\n";
cout << "1 - Do loop\n";
cout << "2 - For loop\n";
cout << "3 - Do while loop\n\n";
cout << "4 -Exit\n\n";

cout << "Choice: ";
cin >> choice;
// Demonstrates the switch statement.
//When you pick the loop, the cases is how you get the average of your numbers.

switch (choice)
{
case 1:
{
a = DOWHILELOOP();
cout << "\You have chosen Dowhile loop.";
cout << "\The average is:" << a;
}
break;

case 2:
{
b = FORLOOP();
cout << "\You have chosen For Loop.";
cout << "\The average is:" << b;
}
break;

case 3:
{
c = WHILELOOP();
cout << "\You have chosen While Loop.";
cout << "\The average is:" << c;

}
break;

case 4:
{
cout << "Goodbye";
}
break;

default:
{
cout << "You made an illegal choice.\n";
}
break;
}

return 0;
}
}
}
float FORLOOP()
{



//This is the for loop.
float average;
int num, total = 0;
for (int i = 0; i < 5; i++)
{
cout << "Eneter an Intger:";
cin >> num;
total += num;
}
//average
average = total / 5;
return average;

}
float DOWHILELOOP()
{
float average;
int count = 0;
int num = 0, total = 0;

do
{
float average;
cout << "Please enter an intger:";
cin >> num;
total += num;
count++;
} while (count < 5);
average = total / 5;
return average;
}


float WHILELOOP()
{
float average;
int count = 0;
int num = 0;
int total = 0;
while (count < 5)
{
cout << "Enter an Intger:";
cin >> num;
total += num;
count++;
}
//Taking the avg.
average = total / 5;
cout << "The avergae is:" << average << endl;
return average;
}
}
}
From a glance I see you got some rogue brackets. You should use the code tags and format it a little bit to make it more readable.
Topic archived. No new replies allowed.