How do you implement a binary number to convert into an equivalent decimal number using stack in C++.I am having a headache here.I have been thinking the past 2 days but without much knowledge in C++ i am partially dead. Tried reading books but still can't figure it out and time is running short on me.Please advice and help.Thanks in advance
Kellaw
0
Newbie Poster
Recommended Answers
Jump to PostWell I can only assume your stack was built using notes you obtained from class.
With those notes you should also have a little snippnet detailing how you might actually use your stack inside int main().
You don't necessarily need to put your stack inside another header file …
Jump to PostYou're definitely on the right track.
i already know how to separate 1010 into single digits.
Code:
x=1010;
stack.push((x/(power(10,i))%10);Wouldn't it be easier to represent the binary number as characters, then you could just access each cell with a pointer.
and in the stack the digits are pushed into single …
Jump to Post>No offense man, but that is technically doing it most of the work for him..how can he learn then?
That's nice, but if you read before most of that code was written by him, I just showed him how to use it with chars.
>Do leave me with …
Jump to Post>for (i=0;i<15;i++)
stack.push(x/(power(10,i))%10)I honestly have no idea why you would want to do it that way instead of using chars? Obviously, I've never worked with peripheral devices like bar scanners so I don't know how the information is coming in.
It seems odd though, that you insist …
Jump to Posthey all
first i am web developer not software one, but i had knowledge in algorothem.
kellaw i won't write code only i will tell u the algorithgm.
i suppose the binary stack is stored in array (A) from left to right.
first create 2 arrays (B) and (C) with …
All 44 Replies
Kellaw
0
Newbie Poster
Salem
5,138
Posting Sage

iamthwee
Kellaw
0
Newbie Poster

iamthwee
Kellaw
0
Newbie Poster
Lerner
582
Nearly a Posting Maven
Kellaw
0
Newbie Poster
Lerner
582
Nearly a Posting Maven
Kellaw
0
Newbie Poster

iamthwee
dreamreaver
0
Newbie Poster

iamthwee
Kellaw
0
Newbie Poster
Lerner
582
Nearly a Posting Maven
Kellaw
0
Newbie Poster

iamthwee
Kellaw
0
Newbie Poster

iamthwee
Kellaw
0
Newbie Poster
Kellaw
0
Newbie Poster

iamthwee

iamthwee
Kellaw
0
Newbie Poster
Lerner
582
Nearly a Posting Maven
Lerner
582
Nearly a Posting Maven
Kellaw
0
Newbie Poster
Kellaw
0
Newbie Poster

iamthwee
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.