SlideShare a Scribd company logo
In C Programming create a program that converts a number from decimal to binary. You must
use a stack to complete this assignment. • Void pop() • Void push(int data) • Int top() •
Int isEmpty() You must create an implementation of a stack. You may use either an array or a
linked list as the underlying structure. You will, at a minimum, need to implement the following
stack functions: Your program should take decimal input from the user, and convert it to binary,
and simply print it out.
Solution
normal program
#include<stdio.h>
int main(){
long int decimalNumber,remainder,quotient;
int binaryNumber[100],i=1,j;
printf("Enter any decimal number: ");
scanf("%ld",&decimalNumber);
quotient = decimalNumber;
while(quotient!=0){
binaryNumber[i++]= quotient % 2;
quotient = quotient / 2;
}
printf("Equivalent binary value of decimal number %d: ",decimalNumber);
for(j = i -1 ;j> 0;j--)
printf("%d",binaryNumber[j]);
return 0;
}
using stack
Ad

Recommended

DOCX
In C Programming- Create a program that converts a number from decimal.docx
mckerliejonelle
 
DOCX
Program flowchart
Sowri Rajan
 
PDF
Stack Applications : Infix to postfix conversion, Evaluation of postfix expre...
Dr. Madhuri Jawale
 
DOCX
c plus plus programsSlide
harman kaur
 
PDF
C programs
Vikram Nandini
 
DOCX
Lab. Programs in C
Saket Pathak
 
PPTX
02-binary.pptx
KaziRumayetIslam
 
PPTX
Introduction to binary
Gerrianne Roberts
 
PPTX
CO for classroom observation presentation
chricylmaeleganad
 
PPTX
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
Bilal Amjad
 
DOCX
C lab
rajni kaushal
 
DOCX
programs of c www.eakanchha.com
Akanchha Agrawal
 
DOCX
B.Com 1year Lab programs
Prasadu Peddi
 
PDF
C Programming by SĂĽleyman Kondakci
SĂĽleyman Kondakci
 
PPTX
Basic python programs
RaginiJain21
 
PPTX
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
DOC
Useful c programs
MD SHAH FAHAD
 
PPTX
Data Representation
Education Front
 
PPTX
Q1W3D1 CONVERSION OF COMPUTER NUMBER SYSTEMS (DECIMAL TO BINARY).pptx
JessalynReybuenan
 
DOCX
Taller número 1 de informática ll
ramivides
 
PPTX
Najmul
Najmul Ashik
 
PPTX
Binary decimal conversion
Martin Jacob
 
DOC
Network lab manual
Prabhu D
 
PPTX
Data Representation
Education Front
 
DOCX
1122230 question
lpss0513
 
PPTX
TLE_WEEK6_7_8_PMC.pptx
ssuser652085
 
PDF
II Floating Point Representation Using Strings Understanding how float.pdf
asarudheen07
 
DOCX
In a symmetric multiprocessor configuration- AH processors can perform.docx
tristans3
 
DOCX
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
tristans3
 

More Related Content

Similar to In C Programming create a program that converts a number from decimal.docx (20)

PPTX
Introduction to binary
Gerrianne Roberts
 
PPTX
CO for classroom observation presentation
chricylmaeleganad
 
PPTX
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
Bilal Amjad
 
DOCX
C lab
rajni kaushal
 
DOCX
programs of c www.eakanchha.com
Akanchha Agrawal
 
DOCX
B.Com 1year Lab programs
Prasadu Peddi
 
PDF
C Programming by SĂĽleyman Kondakci
SĂĽleyman Kondakci
 
PPTX
Basic python programs
RaginiJain21
 
PPTX
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
DOC
Useful c programs
MD SHAH FAHAD
 
PPTX
Data Representation
Education Front
 
PPTX
Q1W3D1 CONVERSION OF COMPUTER NUMBER SYSTEMS (DECIMAL TO BINARY).pptx
JessalynReybuenan
 
DOCX
Taller número 1 de informática ll
ramivides
 
PPTX
Najmul
Najmul Ashik
 
PPTX
Binary decimal conversion
Martin Jacob
 
DOC
Network lab manual
Prabhu D
 
PPTX
Data Representation
Education Front
 
DOCX
1122230 question
lpss0513
 
PPTX
TLE_WEEK6_7_8_PMC.pptx
ssuser652085
 
PDF
II Floating Point Representation Using Strings Understanding how float.pdf
asarudheen07
 
Introduction to binary
Gerrianne Roberts
 
CO for classroom observation presentation
chricylmaeleganad
 
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
Bilal Amjad
 
C lab
rajni kaushal
 
programs of c www.eakanchha.com
Akanchha Agrawal
 
B.Com 1year Lab programs
Prasadu Peddi
 
C Programming by SĂĽleyman Kondakci
SĂĽleyman Kondakci
 
Basic python programs
RaginiJain21
 
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
Useful c programs
MD SHAH FAHAD
 
Data Representation
Education Front
 
Q1W3D1 CONVERSION OF COMPUTER NUMBER SYSTEMS (DECIMAL TO BINARY).pptx
JessalynReybuenan
 
Taller número 1 de informática ll
ramivides
 
Najmul
Najmul Ashik
 
Binary decimal conversion
Martin Jacob
 
Network lab manual
Prabhu D
 
Data Representation
Education Front
 
1122230 question
lpss0513
 
TLE_WEEK6_7_8_PMC.pptx
ssuser652085
 
II Floating Point Representation Using Strings Understanding how float.pdf
asarudheen07
 

More from tristans3 (20)

DOCX
In a symmetric multiprocessor configuration- AH processors can perform.docx
tristans3
 
DOCX
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
tristans3
 
DOCX
In chapter 2- 5 objectives of memory management were discussed- In Cha.docx
tristans3
 
DOCX
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
tristans3
 
DOCX
In c- Topic pointers Why do they call it dereferencing- As in derefer.docx
tristans3
 
DOCX
In C++ a function used to put data into a stack is typically called a.docx
tristans3
 
DOCX
In an alternative universe- all rules governing quantum numbers and th.docx
tristans3
 
DOCX
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
tristans3
 
DOCX
In a Classical model of the macroeconomy- the equilibrating mechanism.docx
tristans3
 
DOCX
In 2012- Shurtleff estimates that warranty costs in the following year.docx
tristans3
 
DOCX
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
tristans3
 
DOCX
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
tristans3
 
DOCX
Impulse and momentum are two two different parameters- Explain these p.docx
tristans3
 
DOCX
Implementation of EHR Discuss the advantages and disadvantages associa.docx
tristans3
 
DOCX
Implementing a new AIS system could prove to be beneficial or detrimen.docx
tristans3
 
DOCX
Im creating a stack class using generics- what should my peek method l.docx
tristans3
 
DOCX
ii)State whether you would expect the following Group 13 metal cations.docx
tristans3
 
DOCX
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
tristans3
 
DOCX
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
tristans3
 
DOCX
2- The Mars Climate Orbiter (formerly the Mars Surveyor 98 Orbiter) wa.docx
tristans3
 
In a symmetric multiprocessor configuration- AH processors can perform.docx
tristans3
 
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
tristans3
 
In chapter 2- 5 objectives of memory management were discussed- In Cha.docx
tristans3
 
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
tristans3
 
In c- Topic pointers Why do they call it dereferencing- As in derefer.docx
tristans3
 
In C++ a function used to put data into a stack is typically called a.docx
tristans3
 
In an alternative universe- all rules governing quantum numbers and th.docx
tristans3
 
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
tristans3
 
In a Classical model of the macroeconomy- the equilibrating mechanism.docx
tristans3
 
In 2012- Shurtleff estimates that warranty costs in the following year.docx
tristans3
 
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
tristans3
 
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
tristans3
 
Impulse and momentum are two two different parameters- Explain these p.docx
tristans3
 
Implementation of EHR Discuss the advantages and disadvantages associa.docx
tristans3
 
Implementing a new AIS system could prove to be beneficial or detrimen.docx
tristans3
 
Im creating a stack class using generics- what should my peek method l.docx
tristans3
 
ii)State whether you would expect the following Group 13 metal cations.docx
tristans3
 
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
tristans3
 
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
tristans3
 
2- The Mars Climate Orbiter (formerly the Mars Surveyor 98 Orbiter) wa.docx
tristans3
 
Ad

Recently uploaded (20)

PPTX
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
PPTX
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
PPTX
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
PDF
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PDF
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
PPTX
How to use _name_search() method in Odoo 18
Celine George
 
PDF
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
PPTX
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
PDF
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
PPTX
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
PPTX
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
PPTX
How payment terms are configured in Odoo 18
Celine George
 
PDF
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
PDF
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
PDF
VCE Literature Section A Exam Response Guide
jpinnuck
 
PDF
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
PPTX
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
PPTX
List View Components in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
How to use _name_search() method in Odoo 18
Celine George
 
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
How payment terms are configured in Odoo 18
Celine George
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
VCE Literature Section A Exam Response Guide
jpinnuck
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
List View Components in Odoo 18 - Odoo Slides
Celine George
 
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
Ad

In C Programming create a program that converts a number from decimal.docx

  • 1. In C Programming create a program that converts a number from decimal to binary. You must use a stack to complete this assignment. • Void pop() • Void push(int data) • Int top() • Int isEmpty() You must create an implementation of a stack. You may use either an array or a linked list as the underlying structure. You will, at a minimum, need to implement the following stack functions: Your program should take decimal input from the user, and convert it to binary, and simply print it out. Solution normal program #include<stdio.h> int main(){ long int decimalNumber,remainder,quotient; int binaryNumber[100],i=1,j; printf("Enter any decimal number: "); scanf("%ld",&decimalNumber); quotient = decimalNumber; while(quotient!=0){ binaryNumber[i++]= quotient % 2; quotient = quotient / 2; } printf("Equivalent binary value of decimal number %d: ",decimalNumber); for(j = i -1 ;j> 0;j--)