Hello, i'm very new to the programming, so as of now, i'm really terrible at it :D
I am trying to learn C++ while doing different tasks and this is one task which made me struggle a lot:

"There are x players in a team. Create a program that shows, how many players are taller than 175cm. The height of all the players are typed in via keyboard".

I am not even sure where shall i start, though i was able to successfully solve a good deal of other tasks. Any type of help would be appreciated!
How you would do this if I was telling you numbers, and when I'd finished you had to tell me how many of those numbers were bigger than 175?

Now program that.
Your last sentence is exactly, what i am not able to do.. Like i said, i'm pretty much terrible at this thing.
Shall i use if, else?
http://www.cplusplus.com/doc/tutorial/control/

this page is very handy in my opinion. Im not sure if you are familiar with different loops but if not, this page explains them well.
So do i have to use the loops here? If yes, i still do not know how.
I really need this, so if anyone could write me the code, it would be really appreciated!
 ``1234567891011121314151617181920212223242526272829303132333435`` ``````#include using namespace std; #include struct player { float height; float weight; }; void main() { int nrPlayers; cout<<"Nr. of players ="; cin>>nrPlayers; deque players; players.resize(nrPlayers); for (int i=0; i< nrPlayers; i++) { cout<<"insert player"<> players[i].height; } cout<175) cout<<"player"<
Thank you! Appreciate it!
this is another way, which might be consider way easier(space it if u want it):
 ``1234567891011121314151617181920212223`` ``````#include #include using namespace std; int main(){ int x; int z=0; int *p; int players; cout<< "How many players are there on the team? "; cin>> players; p = new (nothrow) int [players]; for (x = 0; x<= players-1; x++){ printf("Heigh in centimeters for player %d: ", x+1); cin>> p[x]; } for (x = 0; x<=players;x++){ if (p[x] > 175){ z+=1; } } cout<
Last edited on
Topic archived. No new replies allowed.