Need helps with this! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Need helps with this!

To study at a university, you must score higher than or equal to 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 I passed the first one, but I don’t get the second one “else” All my output is pass even though I put else statement on it

7th Jan 2022, 3:01 AM
Altesse
16 Answers
+ 11
Give cin>>score; Instead of score = 100; And use cout instead of printf kindly write cout in this way cout<<"pass"; Try it once again!! Best of luck 👍
7th Jan 2022, 3:15 AM
Aysha
Aysha - avatar
+ 4
Altesse would you please share your code here so we can solve your doubt
7th Jan 2022, 3:05 AM
Aysha
Aysha - avatar
+ 4
Thanks, it makes sense!
7th Jan 2022, 3:48 AM
Altesse
+ 3
#include <iostream> using namespace std; int main() { int score; score = 100; if ( score >= 90) { printf("pass"); } else { printf("fail"); } //your code goes here return 0; }
7th Jan 2022, 3:09 AM
Altesse
+ 3
Yea, It works!!
7th Jan 2022, 3:20 AM
Altesse
+ 2
But can you guys explain me, why it doesn’t work before and what cin>>mean
7th Jan 2022, 3:21 AM
Altesse
+ 2
Altesse cin is the character stream object used in C++ for getting console input (hence, the name, cin). When Code Coach gives you starter code, usually you will find a comment that says "your code goes here". You won't need to edit the starter code. Just add your own code after that comment.
9th Jan 2022, 1:10 AM
Brian
Brian - avatar
+ 1
#include<iostream> using namespace std; int main() { int points; cout<<"Enter your points:"; cin>>points; if(points>=90) { cout<<"pass"; } else { cout<<"fail"; } return 0; }
7th Jan 2022, 5:44 AM
Muhammad Rizwan
Muhammad Rizwan - avatar
+ 1
cin works like scanf. scanf and printf works for c but cin and cout are respectively used in c++
8th Jan 2022, 4:39 PM
Ankith R V
Ankith R V - avatar
+ 1
#include <iostream> using namespace std; int main() { double points; cin >> points; if (points > 89) { cout << "pass"<< endl; } else { cout << "fail" << endl; } //your code goes here return 0; } Good Luck
25th Jan 2022, 11:27 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
0
#include<iostream> using namespace std; int main(){ int score; cin >> score; if(score > 90 || score == 90) cout << "pass"; else cout << "fail"; }
8th Jan 2022, 10:43 AM
IC027-ANKUSH LADANI
0
//it's very easy #include<iostream> using namespace std; int main() { float point; cout<<"Enter Marks : "; cin>>point; if(point >= 90.0) { cout<<"\nPass 👏👏👏"; } else { cout<<"\nSorry, you are FAIL, try again next time all the best 👍; } return 0; } }
8th Jan 2022, 1:45 PM
RTB
RTB - avatar
0
Int x ; scanf(x): If (x >= 90 & X < 100) { Printf('PASS'); } ELSE { PRINTF('FAIL'): }
8th Jan 2022, 7:17 PM
kode pruthviraj
kode pruthviraj - avatar
0
#include ...... ........ ........... int score; cout << "enter the scores"; cin >>scores; if (scores > 90 ){ cout << "you passed \n"; } else { cout "you failed \n"; } //This' the simplest way to do!😎
8th Jan 2022, 8:06 PM
yuenli geoxao
0
You are given a Point class, which defines a point on a 2D grid (x, y). The program creates a Point in main based on user input and calls the shift() function, which should increment the coordinates by the given step. However, the code is not working, as the coordinates are private. Modify the code to fix it.
5th Apr 2023, 7:26 AM
Alalinga Fatawu Iddrisu
Alalinga Fatawu Iddrisu - avatar
0
Fill in the blanks to set the points value based on the category value, which is a char. int points = 0; if(category == 'A') points = 100; } else if(category == 'B') { points = 70; else { points = 50; }
12th Jul 2023, 11:05 AM
Chala Asfaw
Chala Asfaw - avatar