Why campiler give error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
20th Dec 2020, 1:03 PM
Arash
Arash - avatar
9 Answers
+ 5
Arash , there are 2 warnings when running the code: int a; char b; int c; double d = c*a/100; // <------- cin>>a>>b>>c; both are from the line which is marked. You are using 2 variables "a" and "c" that are both NOT initialized with a value, since cin is used in the next line. This can cause problems. swap this 2 lines to run the code.
20th Dec 2020, 1:25 PM
Lothar
Lothar - avatar
+ 4
everything works fine, you just have to give input like this: 2 * 4 instead of 2*4
20th Dec 2020, 3:23 PM
Иван Чикyнов
Иван Чикyнов - avatar
+ 4
If you input an unrecognised operator, the code output will be 'error'.
21st Dec 2020, 9:07 AM
Sonic
Sonic - avatar
+ 3
It's not error but a warning. You have defined variable `d` but haven't used it anywhere in code. Either remove line 8 or comment it down like this: //double d;
20th Dec 2020, 1:08 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 3
Arash Remove this line: double d = c*a/100; Change this line: cout<<a<<"%"<<c<<"="<<d; To: cout<<a<<"%"<<c<<"="a%c; Finish the C++ lesson and use google or bing or read the C++ documentation.
20th Dec 2020, 5:45 PM
Paul K Sadler
Paul K Sadler - avatar
+ 2
Arash , again.. a warning not an error. You are using variables in an expression before assigning a value to them. First take input for variables and then calculate.
20th Dec 2020, 1:17 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
Just remove line 8 and give input 2*3
20th Dec 2020, 1:09 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
I used it in my code but its show error again
20th Dec 2020, 1:12 PM
Arash
Arash - avatar
+ 1
I changed my code and now my problem is double again its not work like decimal number
20th Dec 2020, 1:30 PM
Arash
Arash - avatar