SlideShare a Scribd company logo
1 of 4
In C Programming:
Create a program that converts a number from decimal to binary. A stack MUST be used to
complete the program. Create an implementation of a stack. An array or linked list can be used
as the underlying structure. The following stack functions MUST be implemented into the
program:
• Void pop()
• Void push(int data)
• Int top()
• Int isEmpty()
The program should take decimal input from the user, and convert it to binary, and simply print
it out.
Example: Enter a number to convert to binary: 29 11101
Solution
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define MAX 10
typedef struct stack
{
int data[MAX];
int top;
}stack;
//---------------------
int empty(stack *s)
{
if(s->top==-1)
return(1);
return(0);
}
//----------------------
int full(stack *s)
{
if(s->top==MAX-1)
return(1);
return(0);
}
//-----------------------
void push(stack *s,int x)
{
s->top=s->top+1;
s->data[s->top]=x;
}
//-----------------------
int pop(stack *s)
{
int x;
x=s->data[s->top];
s->top=s->top-1;
return(x);
}
//------------------------
void main()
{
stack s;
int num;
s.top=-1;
printf("nEnter decimal number:");
scanf("%d",&num);
while((num!=0))
{
if(!full(&s))
{
push(&s,num%2);
num=num/2;
}
else
{
printf("nStack overflow");
exit(0);
}
}
printf("n");
while(!empty(&s))
{
num=pop(&s);
printf("%d",num);
}
}

More Related Content

Similar to In C Programming- Create a program that converts a number from decimal.docx

Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5REHAN IJAZ
 
DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++mustkeem khan
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diplomamustkeem khan
 
Write a program that reads in integer as many as the user enters from.docx
Write a program that reads in integer as many as the user enters from.docxWrite a program that reads in integer as many as the user enters from.docx
Write a program that reads in integer as many as the user enters from.docxlez31palka
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)Syed Umair
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cppNilesh Dalvi
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
Write code in c++ Program to a topological sort on a graph Program pl.docx
Write code in c++ Program to a topological sort on a graph  Program pl.docxWrite code in c++ Program to a topological sort on a graph  Program pl.docx
Write code in c++ Program to a topological sort on a graph Program pl.docxnoreendchesterton753
 
Embedded c programming
Embedded c programmingEmbedded c programming
Embedded c programmingPriyaDYP
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++Marco Izzotti
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
power point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions conceptspower point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions conceptsbhargavi804095
 

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

C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
 
Write a program that reads in integer as many as the user enters from.docx
Write a program that reads in integer as many as the user enters from.docxWrite a program that reads in integer as many as the user enters from.docx
Write a program that reads in integer as many as the user enters from.docx
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
Write code in c++ Program to a topological sort on a graph Program pl.docx
Write code in c++ Program to a topological sort on a graph  Program pl.docxWrite code in c++ Program to a topological sort on a graph  Program pl.docx
Write code in c++ Program to a topological sort on a graph Program pl.docx
 
Embedded c programming
Embedded c programmingEmbedded c programming
Embedded c programming
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
 
power point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions conceptspower point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions concepts
 

More from mckerliejonelle

What was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxWhat was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxmckerliejonelle
 
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxWhat subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxmckerliejonelle
 
what type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxwhat type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxmckerliejonelle
 
What skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxWhat skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxmckerliejonelle
 
What pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxWhat pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxmckerliejonelle
 
What percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxWhat percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxmckerliejonelle
 
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxWhat makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxmckerliejonelle
 
What motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxWhat motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxmckerliejonelle
 
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxWHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxmckerliejonelle
 
What is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxWhat is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxmckerliejonelle
 
What is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxWhat is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxmckerliejonelle
 
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxWhat is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxmckerliejonelle
 
What is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxWhat is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxmckerliejonelle
 
What is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxWhat is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxmckerliejonelle
 
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxWhat is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxmckerliejonelle
 
What is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxWhat is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxmckerliejonelle
 
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxWhat is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxmckerliejonelle
 
What is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxWhat is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxmckerliejonelle
 
What is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxWhat is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxmckerliejonelle
 
What is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxWhat is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxmckerliejonelle
 

More from mckerliejonelle (20)

What was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxWhat was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docx
 
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxWhat subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
 
what type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxwhat type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docx
 
What skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxWhat skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docx
 
What pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxWhat pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docx
 
What percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxWhat percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docx
 
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxWhat makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
 
What motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxWhat motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docx
 
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxWHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
 
What is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxWhat is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docx
 
What is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxWhat is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docx
 
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxWhat is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
 
What is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxWhat is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docx
 
What is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxWhat is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docx
 
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxWhat is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
 
What is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxWhat is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docx
 
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxWhat is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
 
What is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxWhat is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docx
 
What is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxWhat is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docx
 
What is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxWhat is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docx
 

Recently uploaded

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Recently uploaded (20)

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . 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. A stack MUST be used to complete the program. Create an implementation of a stack. An array or linked list can be used as the underlying structure. The following stack functions MUST be implemented into the program: • Void pop() • Void push(int data) • Int top() • Int isEmpty() The program should take decimal input from the user, and convert it to binary, and simply print it out. Example: Enter a number to convert to binary: 29 11101 Solution #include<stdio.h> #include<conio.h> #include<process.h> #define MAX 10 typedef struct stack { int data[MAX];
  • 2. int top; }stack; //--------------------- int empty(stack *s) { if(s->top==-1) return(1); return(0); } //---------------------- int full(stack *s) { if(s->top==MAX-1) return(1); return(0); } //----------------------- void push(stack *s,int x) { s->top=s->top+1; s->data[s->top]=x; } //-----------------------
  • 3. int pop(stack *s) { int x; x=s->data[s->top]; s->top=s->top-1; return(x); } //------------------------ void main() { stack s; int num; s.top=-1; printf("nEnter decimal number:"); scanf("%d",&num); while((num!=0)) { if(!full(&s)) { push(&s,num%2); num=num/2; } else