what am i doing wrong here?

i dont know what is wrong with this program. i am not getting any error messages. nothing is printing inside the for loop. if i remove the for loop everything prints. i need the for loop because i have to run it 8 times.
this is my program:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int idnumb, wins, losses, ties, totalgames, remaininggames, finalscore;
double winningaverage;

cout<<"this program will print out the statistics for eight football teams."<< endl;
cout<<"team"<<" ";
for (idnumb=1; idnumb>=8; idnumb=idnumb+1) {
cout<<idnumb<<endl;
cout<<"4 wins"<<" "<<"4 losses"<<" "<< "5 ties"<<endl;
cout<<"total number of games played is"<<" ";
wins=4, losses=4, ties=5;
totalgames=wins+losses+ties;
cout<<totalgames;
cout<<endl;
cout<<"the winning average is"<<" ";
winningaverage= (wins/totalgames);
}
return 0;
}

in your for statement the conditional part ( dont know what its called ) will never be fulfilled since when you initialilze idnumb to be 1. its never going to be >= 8 so it wont even run once. Im pretty sure you mean:
 
for (idnumb=1; idnumb<=8; idnumb++) {

^ There its saying initialize idnumb to be one, and while idnumb is smaller-than or equal to 8 do this (rest of the code) then increment idnumb.
Im sorry im not very good at explaining :p
Last edited on
thanks and you were right. but how come its repeating the same data over and over again. how do i put in different data for each team so they have different number of wins, losses and ties.
How would you like to put in different data?
You can use rand() for random data or you can use cin to get user input
not sure. whenever i put in a cin nothing happens. should i put the for loop around the things that need to be repeated and the put in a data separately for each team but im not sure how that would work.
Well heres an example of cin
1
2
3
4
int wins;
cout << "Please enter in wins \n";
cin >> wins;
cout << "The team won " << wins << " times\n"; 

You could use an array of ints and then just loop it to get wins loses and ties

EDIT: also you dont need to include cmath in your program since you arent using any of its functions. Just search up cmath c++ on google to see everything thats in there.
Last edited on
ok can you show me where i should put it in my program.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int idnumb, wins, losses, ties, totalgames, remaininggames, finalscore;
float winningaverage;

cout<<"this program will print out the statistics for eight football teams."<< endl;
for (idnumb=1; idnumb<=8; idnumb=idnumb+1) {
cout<<"team"<<" ";
cout<<idnumb<<endl;
cout<<"4 wins"<<" "<<"4 losses"<<" "<< "5 ties"<<endl;
cout<<"total number of games played is"<<" ";
wins=4, losses=4, ties=5;
totalgames=wins+losses+ties;
cout<<totalgames;
if (totalgames==16)
cout<<" the season is finished";
else (totalgames<16);
cout<< " the season is not finished";
cout<<endl;
cout<<"the winning average is"<<" ";
winningaverage=((double)wins/totalgames);
cout<<winningaverage<<endl;
if (ties>=wins)
cout<<"the number of games won is greater than or equal to the number of games won"<<endl;
else (ties>=wins);
cout<<"the number of games won is not greater than or equal to the number of games won";
cout<<endl;
}
return 0;
}
thanks
Man come on i dont wanna do your program for you XD

Just make a struck:
1
2
3
struct Team {
    int wins, loses, tied;
};

then get input for them:
1
2
3
4
5
6
7
struct Team teams[8]; //Array of Team - Remember that 0 is the starting number;
for (int i = 0; i < 8; i++)
{
    cout << "Please enter wins\n";
    cin >> teams[i].wins;
    //etc...
}
dont worry i wasnt telling you to do it for me. gotta learn it myself :)
i dont think i can use struck because my prof hasnt taught it yet and he takes off points for every little thing, but thanks though.
Topic archived. No new replies allowed.