answersLogoWhite

0


Best Answer

How do you write a c program to convert decimal no to binary no using stack in c++

User Avatar

Wiki User

โˆ™ 2009-10-29 19:59:23
This answer is:
User Avatar
Study guides

Data Science

โžก๏ธ
See all cards
4.75
โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…
4 Reviews

Add your answer:

Earn +20 pts
Q: How do you write a c program to convert binary to decimal using stack?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How Convert decimal to binary using stack?

using C programming language


Convert decimal number to binary number using stack?

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


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.


A program in c to convert decimal number into binary 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


C program to convert decimal to binary using stack?

void push (int value); /* you write it */ int pop (void); /* you write it */ int isempty (void); /* you write it */ int dec_to_bin (int n, char *to) { . do { . . push (n%2); . . n /= 2; . } while (n); . while (! isempty ()) { . . *to++ = '0' + pop(); . } . *to = '\0'; }


Write a program to convert stack into queue using c language?

In order to write a program to convert stack into queue using c language you must be able to identify the proper program. Having a special certification in programing will be beneficial as well to make sure you recognize the proper queues for the programs.


What is the difference between stack pointer and program counter?

Program counter stores the address of the next instruction to be executed..Stack pointer stores the address of the last program request in the stack


Write a c plus plus program to convert decimal to binary using stack?

Two examples are provided here. The first makes use of the call stack while the second makes use of a local stack. Of the two methods, the latter is the more efficient.Example 1: Call Stack Method#include#include#includestd::string dec_to_bin(unsigned dec){std::string result = "";char c = (dec & 0x1) + '0';if( dec >>= 1)result += dec_to_bin(dec);return result + c;}int main(){// Print the first 256 binary numbers.for (unsigned num=0; num


What is the difference between Program counter and Stack pointer?

Program counter stores the address of the next instruction to be executed..Stack pointer stores the address of the last program request in the stack


What are the different sections of c program?

Well, the source program doesn't have sections, the binary format consist of parts like: read-only executable, read-only data, writeable data, stack, etc


What is the use of stack pointer and program counter?

stack pointer is used to find the address of the stack

People also asked