What is code? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
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

21st Sep 2021, 11:40 AM
Mona Alidi
Mona Alidi - avatar
5 Respuestas
+ 2
if (points >= 90){ cout<<"pass"<<endl; } else { cout<< "fail"<<endl; }
21st Sep 2021, 11:54 AM
Simba
Simba - avatar
+ 1
Thanks
21st Sep 2021, 11:55 AM
Mona Alidi
Mona Alidi - avatar
+ 1
Everyone asks what is code ? But no-one asks how is code ? (Sad code noises.....)
21st Sep 2021, 2:21 PM
Arsenic
Arsenic - avatar
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;
21st Sep 2021, 11:42 AM
Mona Alidi
Mona Alidi - avatar
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....
21st Sep 2021, 11:58 AM
Jayakrishna 🇮🇳