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

More Related Content

DOCX
Core programming in c
DOCX
B.Com 1year Lab programs
DOCX
PPTX
c programming lab for first year student
PDF
Progr3
PDF
C programs
DOCX
C Programming
PPTX
C Language Programming Introduction Lecture
Core programming in c
B.Com 1year Lab programs
c programming lab for first year student
Progr3
C programs
C Programming
C Language Programming Introduction Lecture

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

DOCX
DOCX
Programming fundamentals
DOCX
Dam31303 dti2143 lab sheet 7
DOCX
Chapter 1 Programming Fundamentals Assignment.docx
DOCX
Practical write a c program to reverse a given number
DOCX
Practical write a c program to reverse a given number
PPTX
C Programming Example
PDF
Common problems solving using c
PDF
Basic C Programming Lab Practice
DOC
Programming egs
DOCX
Qust & ans inc
DOCX
Best C Programming Solution
DOCX
Write a program to perform translation
PDF
C Programming Example
DOC
Datastructure notes
DOCX
UNIT-II CP DOC.docx
PDF
Numerical analysis
DOCX
Bti1022 lab sheet 9 10
DOCX
Programming in c
DOCX
Write a program to perform translation.
Programming fundamentals
Dam31303 dti2143 lab sheet 7
Chapter 1 Programming Fundamentals Assignment.docx
Practical write a c program to reverse a given number
Practical write a c program to reverse a given number
C Programming Example
Common problems solving using c
Basic C Programming Lab Practice
Programming egs
Qust & ans inc
Best C Programming Solution
Write a program to perform translation
C Programming Example
Datastructure notes
UNIT-II CP DOC.docx
Numerical analysis
Bti1022 lab sheet 9 10
Programming in c
Write a program to perform translation.
Ad

More from tristans3 (20)

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

Recently uploaded (20)

PDF
Laparoscopic Colorectal Surgery at WLH Hospital
PPTX
Education and Perspectives of Education.pptx
PPTX
Module on health assessment of CHN. pptx
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PDF
plant tissues class 6-7 mcqs chatgpt.pdf
PDF
International_Financial_Reporting_Standa.pdf
PDF
1.Salivary gland disease.pdf 3.Bleeding and Clotting Disorders.pdf important
PPTX
Climate Change and Its Global Impact.pptx
PPT
REGULATION OF RESPIRATION lecture note 200L [Autosaved]-1-1.ppt
PDF
Fun with Grammar (Communicative Activities for the Azar Grammar Series)
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PDF
English Textual Question & Ans (12th Class).pdf
PPTX
What’s under the hood: Parsing standardized learning content for AI
PDF
Journal of Dental Science - UDMY (2020).pdf
PDF
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
PDF
My India Quiz Book_20210205121199924.pdf
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
M.Tech in Aerospace Engineering | BIT Mesra
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
Journal of Dental Science - UDMY (2021).pdf
Laparoscopic Colorectal Surgery at WLH Hospital
Education and Perspectives of Education.pptx
Module on health assessment of CHN. pptx
Cambridge-Practice-Tests-for-IELTS-12.docx
plant tissues class 6-7 mcqs chatgpt.pdf
International_Financial_Reporting_Standa.pdf
1.Salivary gland disease.pdf 3.Bleeding and Clotting Disorders.pdf important
Climate Change and Its Global Impact.pptx
REGULATION OF RESPIRATION lecture note 200L [Autosaved]-1-1.ppt
Fun with Grammar (Communicative Activities for the Azar Grammar Series)
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
English Textual Question & Ans (12th Class).pdf
What’s under the hood: Parsing standardized learning content for AI
Journal of Dental Science - UDMY (2020).pdf
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
My India Quiz Book_20210205121199924.pdf
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
M.Tech in Aerospace Engineering | BIT Mesra
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Journal of Dental Science - UDMY (2021).pdf

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--)