0
What is code?
To study at a university, you must score higher than 90 out of 100 points on an exam. The given program takes points as input. Task Complete the code to output "pass" if the score is higher than or equal to 90, otherwise print "fail". Sample Input 95 Sample Output pass
5 Respuestas
+ 2
if (points >= 90){
cout<<"pass"<<endl;
}
else {
cout<< "fail"<<endl;
}
+ 1
Thanks
+ 1
Everyone asks what is code ?
But no-one asks how is code ?
(Sad code noises.....)
0
My code : #include <iostream>
using namespace std;
int main() {
double points;
cin >> points;
if (points<=100 or points>=100){cout<<"pass"<<endl;}
else if (points>100){cout<< "fail"<<endl;}
//your code goes here
return 0;
0
Check again your logic for just :
output "pass" if the score is higher than or equal to 90,
Else print "fail".
This your code always prints pass because any value is true for your if condition :
if(points<=100 or points>=100){cout<<"pass"<<endl;}
Or operater is results true if any one expression results true. So try to redefie it
for ex: input 90 then points<=100 => 90<=100 is true.
for ex: input 120 then points>=100 => 120>=100 is true.
for ex: input 100 then points<=100 => 100<=100 is true.
by the way, you have consider higher or equal to 90 only....