+ 1

I have to add 041 to 034 and obtain result as 075

But it returns 75 in CPP. What to do..

5th Sep 2020, 12:55 PM
sid
sid - avatar
10 Respuestas
5th Sep 2020, 1:41 PM
MO ELomari
MO ELomari - avatar
+ 3
Well the point is: int x=041 is converted to 41 directly..... You could convert 75 to a String and add 0 afterwards
5th Sep 2020, 1:13 PM
Alexander Thiem
Alexander Thiem - avatar
+ 3
Do you need to take the input as octal values sid? int int1, int2; std::cin >> std::oct >> int1 >> int2; // read inputs as octal numbers.
5th Sep 2020, 1:23 PM
Ipang
+ 3
as @lpang mentioned, you need to take the input as octal (use octal base): std::cin >> std::oct >>a;
5th Sep 2020, 5:52 PM
MO ELomari
MO ELomari - avatar
+ 3
🎸🎸🎸 Web-Learner Alexander Thiem Ipang Mohamed ELomari Thank you for your time guyz.. really appreciated.. Stay Safe..
6th Sep 2020, 4:29 AM
sid
sid - avatar
+ 2
041+034=075 Or 0.41+0.34=0.75 ?
5th Sep 2020, 1:02 PM
Web-Learner
+ 2
int a[3]=new int[0,4,1]; int b[3]=new int[0,7,5]; int res[3]=[a[0]+b[0],a[1]+b[1],[a[2]+b[2]]; 🍻
6th Sep 2020, 3:59 PM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
you are welcome
6th Sep 2020, 4:24 PM
Alexander Thiem
Alexander Thiem - avatar
0
Mohamed ELomari i didnt knew there was a function like this exists.Thank you.. and why this code returns 014 instead of 012. https://code.sololearn.com/ct1vdYOcrSOu/?ref=app
5th Sep 2020, 4:41 PM
sid
sid - avatar