answersLogoWhite

0


Best Answer

becomes heavy because the ang decimal number ay marami kay sa sa stack ng tsinelas

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Convert decimal number to binary number using stack?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

C plus plus program that convert decimal to binary using the concept of stack?

#include<stdio.h> #include<stdlib.h> main() { int number,binary[10000],b=0; printf("Enter decimal number "); scanf("%d",&number); printf("\nBinary: "); for(;number;number/=2,b++) binary[b]=number%2; for(b--;b>-1;b--) printf("%d ",binary[b]); }


How do you write a C program to convert a binary value to its octal equivalent?

To convert from binary to octal, bitwise AND the binary value with 0x8 (00000111 in binary) and push the value onto a stack. Right-shift (>>) the binary value by 3 bits and repeat until the binary value is zero. Pop the stack to build the left-to-right digits of the octal value. Using 10110100 as an example: 10110100 & 00000111 = 00000100 10110100 >> 3 = 00010110 00010110 & 00000111 = 00000110 00010110 >> 3 = 00000010 00000010 & 00000111 = 00000010 00000010 >> 3 = 00000000 Popping the values in order reveals 00000010, 00000110 and 00000100 (decimal 2, 6 and 4 respectively). Thus 10110100 binary is 0264 octal.


Write a program to convert hexadecimal to decimal numbers?

write an assembly language program to implement a stack. START: LXI SP,STACK ;initialize stack pointer LXI H,BINBYT ;point HL index to where binary number is stored MOV A,M ;transfer byte LXI H,OUTBUF ;point HL index to output-buffer memory CALL BINBCD HLT BINBCD: MVI B,100 ;load 100 into register B (power of ten holding register) CALL BCD ;call conversion for BCD3 MVI B,10 ;load 10 into register B CALL BCD ;call conversion for BCD2 MOV M,A ;store BCD1 RET


How do you write a c program to convert binary to decimal using stack?

ALGORITHM: function outputInBinary(Integer n) Stack s = new Stack while n > 0 do Integer bit = n modulo 2 s.push(bit) if s is fullthen return error end if n = floor(n / 2) end while while s is not empty dooutput(s.pop()) end while end function


How to convert prefix to postfix?

convert to perfixed to postfixed


How binary tree is effective or better or advantaeous compared to other data representations like the stack queue and linked lists?

Binary trees main advantages are in searching and sorting. Algorithms for searching binary trees (Binary search trees) worst case ie. least efficient is when all the data is in a chain with no sub trees (like a linked list).So for data stored in a binary tree, at worst it will be as effective for searching and sorting as a linked list, stack etc. At best it will be much faster.The only disadvantage I can think of is reordering the tree on removal of an element is a little more complex than in say a list or stack. But still quite easy to implement.


How tall is a stack of 35 boxes if the height of each box is 24 centimeter?

The stack will most likely topple. Other than that, the idea is to multiply the number of boxes by the height of each box. You may then want to divide the result by 100, to convert from cm to meters.


Why is there no threading for post order traversal of a binary search tree?

You don't need it. Think about it, you can just use a stack (or a recursive function.)


How Convert decimal to binary using stack?

Decimal to Binary Using a StackThere is no need to program a computer to convert from decimal to binary because all programming languages do this by default; they are binary computers after all. That is, if we want to store the decimal value 42 in computer memory, we simply assign the literal constant 42 to some variable or constant. But the value that is actually assigned is really the binary value 00101010. Moreover, even if we were to assign the hexadecimal value 0x2A or even the octal value 052, the value will still be automatically converted to the binary value 00101010. These are all different representations of the decimal value forty-two, but 00101010 is the only way that value can be physically stored in computer memory. Of course we may choose to store the value as a string, "42", however it is no longer a numeric value at that point, it is a character array. However, most languages will provide some library function that can convert the string representation of a numeric value into their actual numeric representation. In C, for instance, we would simply use the atoi() function. Nevertheless, it is not something we need to specifically cater for; the function does all the hard work for us, converting the string, "42", into the equivalent binary value 00101010. However, although decimal integer values are always stored in native binary code, presenting that binary value to the user isn't as straightforward. All languages will automatically convert the binary value back to decimal for display purposes, but what it's actually doing behind the scenes is converting the binary value 00101010 into the string "42" and then printing the string. In other words, it is the reverse of the atoi() function, essentially the equivalent of the itoa() function. Given that we don't need to program either of these conversions, it's easy to forget that these conversions are taking place. Given that humans work predominantly in decimal it is only natural that these conversions be done automatically for us, but it is a high-level concept; it is an abstraction. While there's nothing wrong in thinking at a high-level, it's important to be aware of the low-level operations that are actually taking place, because the more we know about what's really going on behind the scenes, the more easily we can exploit them. The high-level concept of converting from decimal to binary is only one such example where we can exploit the fact that the conversion to binary is already done for us behind the scenes. All we really need to do is present the result to the user. To achieve this we need to convert the binary value to a string, in much the same way as the itoa() function converts a binary value into a decimal string, except we convert to a binary string. A stack makes this incredibly simple. We simply examine the low-order bit and push a '1' character onto the stack if the bit is set, otherwise we push a '0'. We then shift all the bits one bit to the right and repeat the process. We continue in this manner until the binary value is zero. If the number of elements on the stack is not an exact multiple of 8, we can (optionally) push additional '0' characters onto the stack for padding. Finally, we print the top-most element on the stack and then pop it off the stack, repeating until the stack is empty. Thus if we use the value 00101010 once more, we examine the low-order bit. It is not set so we push a '0' onto the (empty) stack. We then shift the bits one place to the right, giving us 00010101. The low-order bit is now set so we push a '1'. We repeat the process, pushing a '0', then a '1', another '0' and another '1'. At this stage, the binary value is 00000000 so we are done. The stack has only six elements so we (optionally) push another two '0' characters onto the stack for padding. Now we begin popping the stack, printing the top-most element before each pop. When we are done, we will have output the character sequence "00101010". The following code in C++ shows how this might be implemented as a function. The return value is a string containing the binary representation of the function argument, dec. std::string dec2bin(int dec) { std::stack s {}; initialise an empty stack of characters while (dec) { if (dec & 0x1) // if the low-order bit is set... s.push ('1'); else s.push ('0'); dec >>= 0x1; // shift-right } while (s.size() % 8) s.push('0'); // pad the stack to the nearest 8-bit boundary std::string bin {}; // initialise return value (empty string)while (!s.empty()) {bin.append (s.top());s.pop();}return bin;} Example usage:int main() {std::cout > i;std::cout


In World of Warcraft how do you split a stack in your inventory?

You shift click on the stack you want to split, and a little box will pop up asking for the stack size. Either type in the number or use the arrows on the box to select a number. When you hit ok, the client will take out the number you selected and put it in a stack on your cursor, be sure to click on an empty space in you bags to create the new stack.


The height of a stack of dimes varies directly with the number of dimes in the stack A stack of 4 dimes is 5.4 mm tall How many dimes are in a stack that is 27 mm tall?

20 dimes


How many stack used in DOS?

number Specifies the number of stacks (0 or 8 to 64) that are to be set aside for hardware interrupts.