Quick q

I have a quick question about the program. It is saying that my variables under float are constantly not being initialized. Please let me know if You can solve it. Thanks.

//-----------------------------------------

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

int main()

{

//declare identifiers

string Name;

float first,second,third,fourth,fifth,sixth,average, saverage;

cout<<fixed<<showpoint<<setprecision(2);

//Show formula

average=(first+second+third)/(3.);

saverage=(fourth+fifth+sixth)/(3.);

//Get data

cout<<"Please enter your name:";cin>>Name;

cout<<Name<<", enter your scores in 3 exams:";cin>>first>>second>>third;

cout<<Name<<", enter your scores in 3 quizes:";cin>>fourth>>fifth>>sixth;

cout<<"Dear "<<Name<<","<<endl;

cout<<" Your exams average is"<<average<<"and quizzes average is"<<saverage<<endl;

cout<<" It seems that you are doing great."<<endl;

cout<<"\t\t\t\t Your advisor"<<endl;

 

system ("pause");

return 0;

}
[/code]
That is because you try to use them before you initialize them. For example, you set average = (first+second+third)/(3.), but first, second, and third haven't been given a value yet.
Topic archived. No new replies allowed.