Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Counting top students
/* ** Counting top students** This challenge is to count how many students scored 90 or more on a test. Your program should read in a sequence of whole numbers, stopping when -1 is entered, and display how many of the numbers were 90 or more. If a number less than -1 or more than 100 is entered, an error message should be displayed. */ //g++ 5.4.0 #include <iostream> #include <string> using namespace std; int main() { // std::cout << "Hello, world!\n"; //declare index and counter. int i=0; int numOfElements=0; //delare array and assign input values int input[7]={30,122,94,98,-1,50,100}; for (i=0;i<7;i++){ int inputs=input[i]; // std::cout<<inputs<<'\n'; if (inputs==-1){ std::cout<<inputs<<" stop activated"<<'\n'; break; } if (inputs<-1||inputs>100){ std::cout<<inputs<<" is not a valid number"<<'\n'; } if (inputs>=90&&inputs<=100){ numOfElements++; } }std::cout<<"number of scores greater than 90 is: "<<numOfElements<<'\n'; return 0; }
run
|
edit
|
history
|
help
0
2021(M2)Simulare:S3:1
Reverse a string
Dar
Continuous Sub Set with given sum
hilbert
Lekhana.R 123454766
OverloadFunc
series kv type 1
DailyGroceryHisto
Sieve Of Eratosthenes