Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write the programme that convert a interger to biniry number

Answer Posted / bunny_1996

import java.util.Scanner;
public class HelloWorld{

public static void main(String []args){
Scanner scr=new Scanner(System.in);
int no,i=0,a=0;
int [] x=new int[20];
System.out.println("Enter the decimal number");
no=scr.nextInt();
while(no!=0)
{
a=no%2;
no=no/2;
x[i]=a;
i++;
}
int len=i;
for(i=len-1;i>=0;i--)
{
System.out.print(""+x[i]);
}
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Should the member functions which are made public in the base class be hidden?

1034


Can manipulators fall in love?

1016


What are the advantages of using a pointer? Define the operators that can be used with a pointer.

1034


How can I disable the "echo" feature?

1176


Where must the declaration of a friend function appear?

961


What is null pointer and void pointer and what is their use?

1102


What is difference between class and structure in c++?

1210


What is an overflow error?

1106


How should a contructor handle a failure?

1194


What does the linker do?

1043


How will you call C functions from C ++ and vice-versa?

1145


What is a loop? What are different types of loops in c++?

1133


What are abstract data types in c++?

986


Are c and c++ similar?

1056


what is COPY CONSTRUCTOR and what is it used for?

1075