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!
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!
#include <iostream>
#include <stdio.h>
usingnamespace 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<<z-1<< " players are taller than 175 centimeters.";
return 0;
}