+ 4
What's wrong with code?
I'm trying to make its say 36.1 - 37.1 is OK but anything under or over isn't ok https://code.sololearn.com/cdX2913l75i2/?ref=app?
32 ответов
+ 6
In your code i noticed two errors fist one u used cin>>a; and a Variable is defined after cin so its error
Second one is you put semicolon in if condition remove it
.see this code
#include <iostream>
using namespace std;
int main() {
int a;
cin << a;
float x = 36.9;
float y = 36.1;
if(a<y || a>=x)
cout << "ok" << endl;
cout << "Not ok" << endl;
}
+ 8
Lugli if first condition will be true then it wont check any other condition if first one will false then it will Check else if condition it this will also false then else part will execute u can use only if statement instead of else if and else statements.
+ 7
https://code.sololearn.com/cdX2913l75i2/?ref=app
This is the code Ipang
I am not an expert of C++, so I can't help.
+ 4
♨️♨️ I didn't understand about the first error you're talking about. What's wrong in that? Float a; means both definition and declaration so we have allocated a memory for the variable and cin>>a; will store a value in a.
+ 2
Ananthu SV else is not compulsory u can use if instead of else statement.
+ 2
Azudi kenneth Chinedu In MS Windows programs can save data in the Windows Registry. They use system API calls to do that.
+ 1
With 'a' declared as an int type, the value can never be within the accepted range. You should declare it as float.
+ 1
You use if ladder means if all the condition true then every statement execute
+ 1
If you need source code to adjust this then message me i will respond
+ 1
♨️♨️
I think this must be the code he is looking for 😅
#include <iostream>
using namespace std;
int main() {
float a;
cin >> a;
float x = 36.9;
float y = 36.1;
if(a>=y && a<=x)
{
cout << "OK" << endl ;
}else{
cout << "Not ok" << endl;
}
}
+ 1
Azudi kenneth Chinedu, this is off topic for the current question. I will be glad to help, but first post it as a new question so we can continue there.
+ 1
https://code.sololearn.com/cwXOpUe2tpJL/?ref=app
just have a look at this
Lugli
0
Move the code link from the title into the Description. Links do not work in title or tags.
0
Gabriele Gatti
I already checked the code, but I just want anyone visiting this thread to also be able to see it, and can respond 👌
0
♨️♨️ Thanks for helping. Just checked ur profile and ur like a coding God you know like 50 languages.
0
Where is else keyword?
0
Ananthu SV yeah that's what I was trying to do Thanks
0
Lugli thats fine bro ✌️😊
0
In 17 line use else if in place of if
#include <iostream>
using namespace std;
int main() {
float a;
cin >> a;
float x = 36.9;
float y = 36.1;
float z = 100;
if(a>=y && a<=x)
{
cout << "OK" << endl ;
}
else if (a>z) {
cout << "stop capping" << endl;
}
else{
cout << "Not ok" << endl;
}
}
0
Abhishek god how does else if work?