+ 2

Why I can't run my code at If and else condition?

Pls help me why my code can't run in if and else condition? I can't upgrade my level because of this.

13th Apr 2024, 10:43 AM
PHY CHANTREA
PHY CHANTREA - avatar
24 Answers
+ 2
That is in Conditionals and Loops Sections I can progress more pls help me maybe program have problems
13th Apr 2024, 10:55 AM
PHY CHANTREA
PHY CHANTREA - avatar
+ 1
This is simple, change your data types from double to int. That's it. The code you provided will work with decimal numbers but you set the data types to double. It will work but not matched the criteria! That's why. When the user inputs a decimal number for points, the program will check if the points are greater than or equal to 90. If they are, it will output "Pass"; otherwise, it will output "Fail". You should be very careful while selecting data types. You know try to debug your own program in different perspectives, it will increase your patience level and cognitive reasoning! #include <iostream> using namespace std; int main() { int points; cin >> points; //your code goes here if(points>=90){ cout<<"Pass"; } else{ cout<<"Fail"; } return 0; } Happy Coding ☺️
13th Apr 2024, 11:04 AM
`ᴴᵗᵗየ
`ᴴᵗᵗየ - avatar
+ 1
The logic for the program to display "Pass" if points are 90 or above, and "Fail" otherwise. It works here in Code Playground. Take a look⤵️ https://sololearn.com/compiler-playground/ces96ns8e1ew/?ref=app
13th Apr 2024, 11:45 AM
`ᴴᵗᵗየ
`ᴴᵗᵗየ - avatar
+ 1
Not a pro
13th Apr 2024, 11:55 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
Can you please attached code here that we can see your efforts and resolve the issue.
13th Apr 2024, 10:45 AM
`ᴴᵗᵗየ
`ᴴᵗᵗየ - avatar
0
#include <iostream> using namespace std; int main() { double points; cin >> points; //your code goes here if(points>=90){ cout<<"Pass"; } else{ cout<<"Fail"; } return 0; }
13th Apr 2024, 10:53 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
Thx for explain 🙏🙏🙏
13th Apr 2024, 11:21 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
I try already it still the same
13th Apr 2024, 11:26 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
Can't run
13th Apr 2024, 11:26 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
#include <iostream> using namespace std; int main() { int points; cin >> points; //your code goes here if (points>=90) {cout<<"Pass"; } else{ cout<<"Fail"; } return 0; }
13th Apr 2024, 11:30 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
May I know where you try this? Is that code coach challange?
13th Apr 2024, 11:34 AM
`ᴴᵗᵗየ
`ᴴᵗᵗየ - avatar
0
No that is my case study
13th Apr 2024, 11:35 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
If I can't run this code I will not progress my level more
13th Apr 2024, 11:36 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
How to do
13th Apr 2024, 11:36 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
Still I don't start the C++ course. Wait for a while bro. Let me start that! I will get u, soon.
13th Apr 2024, 11:38 AM
`ᴴᵗᵗየ
`ᴴᵗᵗየ - avatar
0
I try this code on both my phone and my laptop still no working
13th Apr 2024, 11:38 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
In If conditional and Loops you will see
13th Apr 2024, 11:38 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
After finished Basic
13th Apr 2024, 11:39 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
I wrote the same you why still can run and upgrade
13th Apr 2024, 11:51 AM
PHY CHANTREA
PHY CHANTREA - avatar
0
I need to upgrade more level but stuck in this code can't run and upgrade more
13th Apr 2024, 11:52 AM
PHY CHANTREA
PHY CHANTREA - avatar