0

Decimal to Octal

https://code.sololearn.com/ca10A34A08A2 If I enter 15 as input, it should be 17 in octal. I think I am doing something wrong with the array size that's why after 17 some random values are showing off.

27th Apr 2021, 9:04 PM
Ramisa Fariha
Ramisa Fariha - avatar
9 Respuestas
+ 1
Your decimaltooctal function is not returning anything but you are trying to print returned values. That's why you are getting garbage values. If you wants to print your values using cout in main() then return the converted value from your function https://code.sololearn.com/cds0E8AEVrPM/?ref=app
27th Apr 2021, 9:27 PM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
+ 1
@Martin Thanks @Shail murtaza I want to learn by practicing..I am tired of watching videos,reading chapters even though sometimes it is hard for me to understand the language..so through practicing I am trying at least to learn C++.I know my style of doing code is like the dumbest way but at the same time I am curious to know why it is the dumbest and that is how I want to learn.It's like learning both multiplication and addition as well.
28th Apr 2021, 7:09 AM
Ramisa Fariha
Ramisa Fariha - avatar
+ 1
Ramisa Fariha Ok. It's totally up to you how you learn. 👍👍 But at start I was learning the same way you are. After some time I realized that this is just more time consuming and inefficient. Learning basics of programming language made it easy to learn advance things properly and I was learning faster then before. And at the same time I was writing good codes then before. That was just an advice.
28th Apr 2021, 9:07 AM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
+ 1
@Martin thank you so much
28th Apr 2021, 10:19 AM
Ramisa Fariha
Ramisa Fariha - avatar
0
Ramisa Fariha I guess you are trying to sort things in C++ without knowing the basic knowledge It's like learning multiplication without knowing addition.
27th Apr 2021, 10:01 PM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
0
@Martin bitset<sizeof(int)*8> b(x); This line is converting octal to binary ..what is the use of bitset and also showbase?
28th Apr 2021, 8:22 AM
Ramisa Fariha
Ramisa Fariha - avatar