Write a code snippet to display an integer in a binary format?



Write a code snippet to display an integer in a binary format?..

Answer / Sonu

{"Code": "C++:nint num = 10; // replace with desired integernnstream bin(std::bitset<sizeof(num) * CHAR_BIT>(num).to_string().rbegin(), num < 0 ? std::end(bin) : std::begin(bin)); std::copy(bin.begin(), bin.end(), std::ostream_iterator<char>(std::cout, ""));nPython:nprint(format(10, "b"))"}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Code AllOther Interview Questions

Write code that allows to create only one instance of a class?

1 Answers  


import java.awt.*; import java.awt.event.*; public class Agency extends Frame implements ActionListener { Label l1,l2,l3,l4; Button b1; TextField t1,t2; String s1,s2,s3,s4; public static void main(String args[]) { new Agency().setVisible(true); } public Agency() { super("Gas Agency Package"); setSize(1280,800); setBackground(Color.lightGray); setLayout(null); // setLayout(new BorderLayout()); t1=new TextField(20); t1.setBounds(440,150,200,30); t1.setBackground(Color.white); t2=new TextField(20); t2.setBounds(440,180,200,30); t2.setBackground(Color.white); t2.setEchoChar('*'); l1=new Label("Gas Agency Package"); l1.setBounds(400,30,300,50); l1.setFont(new Font("TimesRoman",Font.BOLD,25)); l1.setAlignment(Label.CENTER); l2=new Label("Enter your ID and Passoword"); l2.setFont(new Font("TimesRoman",Font.BOLD,20)); l2.setBounds(270,80,300,50); l3=new Label("Enter ID"); l2.setFont(new Font ("TimesRoman",Font.BOLD,20)); l3.setBounds(270,150,120,50); l4=new Label("Enter Passoword"); l2.setFont(new Font ("TimesRoman",Font.BOLD,20)); l4.setBounds(270,180,140,50); add(l1); add(l2); add(l3); add(t1); add(l4); add(t2); b1=new Button("Login"); b1.setBackground(Color.white); b1.setBounds(400,280,100,70); b1.addActionListener(this); add(b1); } public void actionPerformed(ActionEvent e) { if(e.getSource()==b1) { s3="svce"; s4="svce"; s1=t1.getText(); s2=t2.getText(); if(s1.equals(s3) && s2.equals(s4)) { //System.out.println("password is correct"); MenuForm m= new MenuForm(); m.setVisible(true); //this.dispose(); } else { System.out.println("password not correct"); } this.dispose(); } } } plzzzzzzz xplain me this java code like why i m including this packages n the whole code plzzzzzz

1 Answers  


Write a Program to find whether the given number is a Armstrong number.

1 Answers   InterGraph,


In LSMW , what does the following error mean and how to rectify it : Incorrect interface data for set 78 in method C . This error is occuring in idoc processing step of LSMW.

1 Answers   Wipro,


Find out the list of roles which gives access to all t-codes in SAP? Thanks in advance.

0 Answers  


utility used to obtain inform regarding the optimizes choice of access strategy for SQL stmts

1 Answers  


Main frame : I have a PS file. 4 records. I need toread a particular field of that file and then add it up. then write the added field along with all other fields

1 Answers  


Write a sql query to find n'th maximum in the database table.

3 Answers   Oracle,


Is it possible to write JAVA program without including any of the packages,such as "import java.io.*"; bcoz I instantly wrote a code without "import..." statement and runned the program on command Line & it worked. the code is: class Person { String name; int age; Person(String s,int a) { name = s; age = a; } accept() { System.out.println(name+"Hi!!!!!"); System.out.println(age); } } class Demo { public static void main(Strings args[])throws IOException { String name = args[0]; int age = Integer.parseInt(args[1]); Person p = new Person(name,age); p.accept(); } }

1 Answers  


What is the coding about how to recognize color in fuzzy logic using Matlab R2009b?

1 Answers  


Hi, I want the code to fetch multiple rows in REXX using RLX and CURSOR. Can anyone help me?

1 Answers  


Write code to add functions, which would work as get and put properties of a class?

0 Answers  


Categories