+ 2

What could be the problem?

So basically my code is failing to compile because it says I'm using an unqualified id before the numeric constant. float num1 = 123.456F; float num2 = 76.234F; It keeps saying there's an error, any tips on how to fix that part of my code?

14th Apr 2020, 12:26 AM
Akebu
Akebu - avatar
17 Antworten
+ 4
Yes , that last F must be f . Small letter not capital letter
14th Apr 2020, 12:30 AM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 4
Bro these languages are case sensitive, so f and F are very different things
14th Apr 2020, 6:46 AM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
14th Apr 2020, 4:02 PM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 3
Akebu just check it ,
14th Apr 2020, 4:04 PM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 1
But technically speaking lowercase 'f'and uppercase 'F' are the same in C++ with the uppercase 'F' being the recommended one when using floats. Anyway I tried that but it says the problem is the the num1 and num2
14th Apr 2020, 6:09 AM
Akebu
Akebu - avatar
+ 1
Yes I know that, that's why F is the recommended one when dealing with C++ because of the destinction. It still won't won't either way because that's not the problem
14th Apr 2020, 10:27 AM
Akebu
Akebu - avatar
+ 1
The two lines themselves seem to be fine. Maybe you can link the entire code for us?
14th Apr 2020, 11:46 AM
Shadow
Shadow - avatar
+ 1
The error is in line 5 , here 123,456F is wrong Correct is 123.456F
14th Apr 2020, 4:03 PM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
+ 1
@Ray Kalash Tiwari thanks
14th Apr 2020, 7:38 PM
Akebu
Akebu - avatar
+ 1
Your welcome bro
14th Apr 2020, 11:58 PM
Raj Kalash Tiwari
Raj Kalash Tiwari - avatar
0
Here's the code: #include <iostream> using namespace std; int main () { float num1 = 123.456F; float num2 = 76.234F; float sum, difference; sum = num1 + num2; cout << "Total: " << num1 << " + " << num2; cout << " = " << sum; difference = num1 - num2; cout << "Total: " << num1 << " - " << num2; cout << " = " << difference; return 0; }
14th Apr 2020, 3:57 PM
Akebu
Akebu - avatar
0
Is ur problem solved???
15th Apr 2020, 5:23 PM
Aditya Narayan Chaurasia
Aditya Narayan Chaurasia - avatar
0
Yes it is
16th Apr 2020, 10:44 PM
Akebu
Akebu - avatar
- 1
Lex Flexz Hello!
15th Apr 2020, 9:07 AM
Akebu
Akebu - avatar
- 1
Привет
15th Apr 2020, 9:49 AM
Lex Flexz
Lex Flexz - avatar
- 2
Hello
15th Apr 2020, 8:51 AM
Lex Flexz
Lex Flexz - avatar
- 2
My
15th Apr 2020, 8:52 AM
Lex Flexz
Lex Flexz - avatar