/*AvRAGE a average program*/
#include <iostream>
using namespace std;
int main(void)
{
system("TITLE AvRAGE++");
system("COLOR 3");
char cDoagain;
double dnumber1 = 0.0;
double dnumber2 = 0.0;
double dnumber3 = 0.0;
double daverage = 0.0;
do
{
system("CLS");
cout << "Welcome, to AvRAGE++!" <<endl;
cout << "Please enter 3 numbers that you would like to average:"<<endl;
cin >> dnumber1;
cin >> dnumber2;
cin >> dnumber3;
daverage =(dnumber1 + dnumber2 + dnumber3) /3;
//need to loop program
cout << "the average for those numbers are:"<< daverage <<endl <<endl;
system("PAUSE");
cout << "Would you like to start again? (Y/N)" <<endl;
cin >> cDoagain;
while (cDoagain == 'y' || cDoagain == 'y')
Venged,
As you have not use the code tags [1] I can't say much about your code formatting, but if you format you code along the line of the following you can easily see that the opening brace { on line 16 dose not have a matching closing brace } on line 31 (as was pointed out by akmalnuernberg).
/*AvRAGE a average program*/
#include <iostream>
usingnamespace std;
int main(void)
{
system("TITLE AvRAGE++");
system("COLOR 3");
char cDoagain;
double dnumber1 = 0.0;
double dnumber2 = 0.0;
double dnumber3 = 0.0;
double daverage = 0.0;
do
{
system("CLS");
cout << "Welcome, to AvRAGE++!" <<endl;
cout << "Please enter 3 numbers that you would like to average:"<<endl;
cin >> dnumber1;
cin >> dnumber2;
cin >> dnumber3;
daverage =(dnumber1 + dnumber2 + dnumber3) /3;
//need to loop program
cout << "the average for those numbers are:"<< daverage <<endl <<endl;
system("PAUSE");
cout << "Would you like to start again? (Y/N)" <<endl;
cin >> cDoagain;
while (cDoagain == 'y' || cDoagain == 'y')
return 0;
}
for what it is worth, my personal preference for braces is to have them on a line of there own and have another level of indentation for the code that comes between them. eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
do
{
if(...)
{
if(...)
{
...
}
}
else
{
...
}
} while(...) // the exception to the brace on it own line
This way it is easy to match up braces and see what is controlling the block of code you are working on. Some people prefer the following style: