SlideShare a Scribd company logo
1 of 2
Download to read offline
public class DecimalToBinary {
public void printBinaryFormat(int number){
int binary[] = new int[25];
int index = 0;
while(number > 0){
binary[index++] = number%2;
number = number/2;
}
for(int i = index-1;i >= 0;i--){
System.out.print(binary[i]);
}
}
public static void main(String a[]){
DecimalToBinary dtb = new DecimalToBinary();
dtb.printBinaryFormat(25);
}
}
Solution
public class DecimalToBinary {
public void printBinaryFormat(int number){
int binary[] = new int[25];
int index = 0;
while(number > 0){
binary[index++] = number%2;
number = number/2;
}
for(int i = index-1;i >= 0;i--){
System.out.print(binary[i]);
}
}
public static void main(String a[]){
DecimalToBinary dtb = new DecimalToBinary();
dtb.printBinaryFormat(25);
}
}

More Related Content

More from anitasahani11

The conch symbolizes social order, respect and power. When the boys .pdf
The conch symbolizes social order, respect and power. When the boys .pdfThe conch symbolizes social order, respect and power. When the boys .pdf
The conch symbolizes social order, respect and power. When the boys .pdfanitasahani11
 
The bone marrow is the wellspring of numerous immune and blood cells.pdf
The bone marrow is the wellspring of numerous immune and blood cells.pdfThe bone marrow is the wellspring of numerous immune and blood cells.pdf
The bone marrow is the wellspring of numerous immune and blood cells.pdfanitasahani11
 
Stanley Miller experiment explains the origin and evolution of earth.pdf
Stanley Miller experiment explains the origin and evolution of earth.pdfStanley Miller experiment explains the origin and evolution of earth.pdf
Stanley Miller experiment explains the origin and evolution of earth.pdfanitasahani11
 
service revenueSolutionservice revenue.pdf
service revenueSolutionservice revenue.pdfservice revenueSolutionservice revenue.pdf
service revenueSolutionservice revenue.pdfanitasahani11
 
#includeiostream #includequeue #includefstream using nam.pdf
#includeiostream #includequeue #includefstream using nam.pdf#includeiostream #includequeue #includefstream using nam.pdf
#includeiostream #includequeue #includefstream using nam.pdfanitasahani11
 
package reservation; import java.util.; For Scanner Class .pdf
 package reservation; import java.util.; For Scanner Class .pdf package reservation; import java.util.; For Scanner Class .pdf
package reservation; import java.util.; For Scanner Class .pdfanitasahani11
 
Traffic intersection is a piece of transportation infrastructure wha.pdf
  Traffic intersection is a piece of transportation infrastructure wha.pdf  Traffic intersection is a piece of transportation infrastructure wha.pdf
Traffic intersection is a piece of transportation infrastructure wha.pdfanitasahani11
 
Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre Step2 .pdf
                     Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre  Step2 .pdf                     Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre  Step2 .pdf
Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre Step2 .pdfanitasahani11
 
ZnOCu2OV2O3,Ni2O3MnO .pdf
                     ZnOCu2OV2O3,Ni2O3MnO                         .pdf                     ZnOCu2OV2O3,Ni2O3MnO                         .pdf
ZnOCu2OV2O3,Ni2O3MnO .pdfanitasahani11
 
There is actually a few differences. Firstly, a p.pdf
                     There is actually a few differences. Firstly, a p.pdf                     There is actually a few differences. Firstly, a p.pdf
There is actually a few differences. Firstly, a p.pdfanitasahani11
 
Hg^2+ is soft acid and thus akin to bind to soft .pdf
                     Hg^2+ is soft acid and thus akin to bind to soft .pdf                     Hg^2+ is soft acid and thus akin to bind to soft .pdf
Hg^2+ is soft acid and thus akin to bind to soft .pdfanitasahani11
 
HCl dissociates into H+ and Cl- in solution. The .pdf
                     HCl dissociates into H+ and Cl- in solution. The .pdf                     HCl dissociates into H+ and Cl- in solution. The .pdf
HCl dissociates into H+ and Cl- in solution. The .pdfanitasahani11
 
e) Compounds A and D are diastereomers. .pdf
                     e) Compounds A and D are diastereomers.          .pdf                     e) Compounds A and D are diastereomers.          .pdf
e) Compounds A and D are diastereomers. .pdfanitasahani11
 
A) The solution that shows the greater pH at equi.pdf
                     A) The solution that shows the greater pH at equi.pdf                     A) The solution that shows the greater pH at equi.pdf
A) The solution that shows the greater pH at equi.pdfanitasahani11
 
Ok, I cant see the fine lines, but it looks like sigma bonds. The wa.pdf
Ok, I cant see the fine lines, but it looks like sigma bonds. The wa.pdfOk, I cant see the fine lines, but it looks like sigma bonds. The wa.pdf
Ok, I cant see the fine lines, but it looks like sigma bonds. The wa.pdfanitasahani11
 
Ans a) Net Exports = Total value of Export - Total value of import .pdf
Ans a) Net Exports = Total value of Export - Total value of import .pdfAns a) Net Exports = Total value of Export - Total value of import .pdf
Ans a) Net Exports = Total value of Export - Total value of import .pdfanitasahani11
 
List of different types of InputOutput An input device that can .pdf
List of different types of InputOutput An input device that can .pdfList of different types of InputOutput An input device that can .pdf
List of different types of InputOutput An input device that can .pdfanitasahani11
 
Ka depends only on temperature and nature of acid and nothing else.pdf
Ka depends only on temperature and nature of acid and nothing else.pdfKa depends only on temperature and nature of acid and nothing else.pdf
Ka depends only on temperature and nature of acid and nothing else.pdfanitasahani11
 
Is comprised of two half reactions...that of Cu gettingoxidized .pdf
Is comprised of two half reactions...that of Cu gettingoxidized .pdfIs comprised of two half reactions...that of Cu gettingoxidized .pdf
Is comprised of two half reactions...that of Cu gettingoxidized .pdfanitasahani11
 
import java.util.Scanner; import java.text.; public class Ave.pdf
import java.util.Scanner; import java.text.; public class Ave.pdfimport java.util.Scanner; import java.text.; public class Ave.pdf
import java.util.Scanner; import java.text.; public class Ave.pdfanitasahani11
 

More from anitasahani11 (20)

The conch symbolizes social order, respect and power. When the boys .pdf
The conch symbolizes social order, respect and power. When the boys .pdfThe conch symbolizes social order, respect and power. When the boys .pdf
The conch symbolizes social order, respect and power. When the boys .pdf
 
The bone marrow is the wellspring of numerous immune and blood cells.pdf
The bone marrow is the wellspring of numerous immune and blood cells.pdfThe bone marrow is the wellspring of numerous immune and blood cells.pdf
The bone marrow is the wellspring of numerous immune and blood cells.pdf
 
Stanley Miller experiment explains the origin and evolution of earth.pdf
Stanley Miller experiment explains the origin and evolution of earth.pdfStanley Miller experiment explains the origin and evolution of earth.pdf
Stanley Miller experiment explains the origin and evolution of earth.pdf
 
service revenueSolutionservice revenue.pdf
service revenueSolutionservice revenue.pdfservice revenueSolutionservice revenue.pdf
service revenueSolutionservice revenue.pdf
 
#includeiostream #includequeue #includefstream using nam.pdf
#includeiostream #includequeue #includefstream using nam.pdf#includeiostream #includequeue #includefstream using nam.pdf
#includeiostream #includequeue #includefstream using nam.pdf
 
package reservation; import java.util.; For Scanner Class .pdf
 package reservation; import java.util.; For Scanner Class .pdf package reservation; import java.util.; For Scanner Class .pdf
package reservation; import java.util.; For Scanner Class .pdf
 
Traffic intersection is a piece of transportation infrastructure wha.pdf
  Traffic intersection is a piece of transportation infrastructure wha.pdf  Traffic intersection is a piece of transportation infrastructure wha.pdf
Traffic intersection is a piece of transportation infrastructure wha.pdf
 
Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre Step2 .pdf
                     Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre  Step2 .pdf                     Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre  Step2 .pdf
Step1 pH =2 ; [H+] = 1 x10^-2 moleslitre Step2 .pdf
 
ZnOCu2OV2O3,Ni2O3MnO .pdf
                     ZnOCu2OV2O3,Ni2O3MnO                         .pdf                     ZnOCu2OV2O3,Ni2O3MnO                         .pdf
ZnOCu2OV2O3,Ni2O3MnO .pdf
 
There is actually a few differences. Firstly, a p.pdf
                     There is actually a few differences. Firstly, a p.pdf                     There is actually a few differences. Firstly, a p.pdf
There is actually a few differences. Firstly, a p.pdf
 
Hg^2+ is soft acid and thus akin to bind to soft .pdf
                     Hg^2+ is soft acid and thus akin to bind to soft .pdf                     Hg^2+ is soft acid and thus akin to bind to soft .pdf
Hg^2+ is soft acid and thus akin to bind to soft .pdf
 
HCl dissociates into H+ and Cl- in solution. The .pdf
                     HCl dissociates into H+ and Cl- in solution. The .pdf                     HCl dissociates into H+ and Cl- in solution. The .pdf
HCl dissociates into H+ and Cl- in solution. The .pdf
 
e) Compounds A and D are diastereomers. .pdf
                     e) Compounds A and D are diastereomers.          .pdf                     e) Compounds A and D are diastereomers.          .pdf
e) Compounds A and D are diastereomers. .pdf
 
A) The solution that shows the greater pH at equi.pdf
                     A) The solution that shows the greater pH at equi.pdf                     A) The solution that shows the greater pH at equi.pdf
A) The solution that shows the greater pH at equi.pdf
 
Ok, I cant see the fine lines, but it looks like sigma bonds. The wa.pdf
Ok, I cant see the fine lines, but it looks like sigma bonds. The wa.pdfOk, I cant see the fine lines, but it looks like sigma bonds. The wa.pdf
Ok, I cant see the fine lines, but it looks like sigma bonds. The wa.pdf
 
Ans a) Net Exports = Total value of Export - Total value of import .pdf
Ans a) Net Exports = Total value of Export - Total value of import .pdfAns a) Net Exports = Total value of Export - Total value of import .pdf
Ans a) Net Exports = Total value of Export - Total value of import .pdf
 
List of different types of InputOutput An input device that can .pdf
List of different types of InputOutput An input device that can .pdfList of different types of InputOutput An input device that can .pdf
List of different types of InputOutput An input device that can .pdf
 
Ka depends only on temperature and nature of acid and nothing else.pdf
Ka depends only on temperature and nature of acid and nothing else.pdfKa depends only on temperature and nature of acid and nothing else.pdf
Ka depends only on temperature and nature of acid and nothing else.pdf
 
Is comprised of two half reactions...that of Cu gettingoxidized .pdf
Is comprised of two half reactions...that of Cu gettingoxidized .pdfIs comprised of two half reactions...that of Cu gettingoxidized .pdf
Is comprised of two half reactions...that of Cu gettingoxidized .pdf
 
import java.util.Scanner; import java.text.; public class Ave.pdf
import java.util.Scanner; import java.text.; public class Ave.pdfimport java.util.Scanner; import java.text.; public class Ave.pdf
import java.util.Scanner; import java.text.; public class Ave.pdf
 

Recently uploaded

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answersdalebeck957
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 

Recently uploaded (20)

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

public class DecimalToBinary {    public void printBinaryFormat(in.pdf

  • 1. public class DecimalToBinary { public void printBinaryFormat(int number){ int binary[] = new int[25]; int index = 0; while(number > 0){ binary[index++] = number%2; number = number/2; } for(int i = index-1;i >= 0;i--){ System.out.print(binary[i]); } } public static void main(String a[]){ DecimalToBinary dtb = new DecimalToBinary(); dtb.printBinaryFormat(25); } } Solution public class DecimalToBinary { public void printBinaryFormat(int number){ int binary[] = new int[25]; int index = 0; while(number > 0){ binary[index++] = number%2; number = number/2; } for(int i = index-1;i >= 0;i--){ System.out.print(binary[i]); } } public static void main(String a[]){
  • 2. DecimalToBinary dtb = new DecimalToBinary(); dtb.printBinaryFormat(25); } }