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


how to convert decimal to binary in c using while loop
without using array

Answers were Sorted based on User's Feedback



how to convert decimal to binary in c using while loop without using array..

Answer / prisonbreak

#include<conio.h>
#include<stdio.h>

main()
{
clrscr();
int a,b,c,d,e,f,g,h,num;
while(1)
{
printf("\t\t\t\nENTER THE NUMBER YOU WISH TO CONVERT\n");
scanf("%d",&num);
if(num<=255) /* 1 BYTE */
{
a=num%2;
b=(num/2)%2;
c=(num/4)%2;
d=(num/8)%2;
e=(num/16)%2;
f=(num/32)%2;
g=(num/64)%2;
h=num/128;
}
printf("\t\t\tTHE BINARY EQUIVALENT FOR %d IS
%d%d%d%d%d%d%d%d",num,h,g,f,e,d,c,b,a);
}
getche();
}

Is This Answer Correct ?    0 Yes 1 No

how to convert decimal to binary in c using while loop without using array..

Answer / mushir

#include<stdio.h>
int main()
{
int n,a[100],i;
printf("Enter any no. :",n);
scanf("%d",&n);
while(n!=0)
{ for(i=0;i<=4;i++)
{
a[i]=n%2;
n=n/2;
}
}
for(i=4;i>=0;i--)
{
printf("%d",a[i]);

}
}

Is This Answer Correct ?    0 Yes 1 No

how to convert decimal to binary in c using while loop without using array..

Answer / muhammad naeem mughal

The best answer to convert decimal to binary is
by Muhammad Naeem Mughal
University of Gujrat Pakistan


#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,i,j,b[100];
cout<<"\n\t\tEnter decimal number: ";
cin>>n;
while (n>0)
{
b[i]=n%2;
n=n/2;
i++;
}
cout<<"\n\t\tBinary is: ";
j=i-1;
for (i=j;j>=0;j--)
{
cout<<b[j];
}
getch();
}

Is This Answer Correct ?    4 Yes 6 No

how to convert decimal to binary in c using while loop without using array..

Answer / jimmy

#include<stdio.h>
#include<conio.h>

void covert2binary(int);


void main()
{
int num;
clrscr();

printf("enter numer: ");
scanf("%d:",&num);

covert2binary(num);


getch();
}


void covert2binary(int n)
{
int i=0,j,b[100];

while (n>0)
{
b[i]=n%2;
n=n/2;
i++;

}

printf("\nBinary is: ");
j=i-1;

for (i=j;j>=0;j--)
{
printf("%d", b[j]);

}


}

Is This Answer Correct ?    5 Yes 8 No

how to convert decimal to binary in c using while loop without using array..

Answer / nirav panchal

#include<stdio.h>
#include<conio.h>
void main()
{
int dec,i=1,rem,res=0;
clrscr();
printf("Enter the Value");
scanf("%d",&dec);
while(dec>0)
{
rem=dec%2;
dec=dec/2;
res=res+(i * rem);
i=i*10;

}
printf("The Binary value is %d",res);
getch();
}

Is This Answer Correct ?    5 Yes 8 No

how to convert decimal to binary in c using while loop without using array..

Answer / pankajashan

Nothng to display

Is This Answer Correct ?    3 Yes 7 No

how to convert decimal to binary in c using while loop without using array..

Answer / aya mohamed

#include<iostream>
using namespace std;
int main()
{
int dec,rem,i=1;
long int bin=0;
printf("Enter the decimal number : ");
scanf("%d",&dec);
while(dec>0)
{
rem=dec%2;
dec=dec/2;
bin=bin+(i*rem);
i=i*10;
}
printf("The binary number is %l",bin);
getch();
}
//main fun must return int number

Is This Answer Correct ?    2 Yes 6 No

how to convert decimal to binary in c using while loop without using array..

Answer / bhavin tank

//decimal to binary using for and array
#include<iostream.h>
#include<conio.h>
void conv(int n)
{
int a[100],i;
for(i=0;n!=0;i++)
{
a[i]=n%2;
n=n/2;
}
cout<<"the binary is";
for(i-=1;i>=0;i--)
{
cout<<a[i];
}
}
void main()
{
clrscr();
int n;
cout<<"enter the no:";
cin>>n;
conv(n);
getch();
}

Is This Answer Correct ?    5 Yes 10 No

how to convert decimal to binary in c using while loop without using array..

Answer / anand raj b

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

void main()
{
int i=23;
char c[23];
clrscr();
cout<<"Enter any Number in Decimal to be converted in Binary\n";
cin>>i;
cout<<itoa(i,c,2);
getch();
}

Is This Answer Correct ?    9 Yes 15 No

how to convert decimal to binary in c using while loop without using array..

Answer / daryl

int main()
{
int a = 0,r[10],dec,quo;
clrscr();

printf("Enter Decimal number: ");
scanf("%i",&quo);

while(quo>0)
{
r[a]=quo%2;
quo=quo/2;
a++;
}

a=a-1;
while(a>=0)
{
printf("%i",r[a]);
a--;
}
getch();
return(0);
}

Is This Answer Correct ?    8 Yes 19 No

Post New Answer

More C C++ Errors Interview Questions

Find the error (2.5*2=5) (a) X=y=z=0.5,2.0-5.75 (b) s=15;

3 Answers  


How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?

1 Answers  


I can not get my C++ program to work right. It is supposed to tell if a word is a palindrome or not, but it only tells thet the word is not a palindrome. And I can't fix it.

1 Answers  


How to develop a program using C language to convert 8-bit binary values to decimals. TQ

1 Answers   Amazon,


Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,


What is the out put of this programme? int a,b,c,d; printf("Enter Number!\n"); scanf("%d",&a); while(a=!0) { printf("Enter numbers/n"); scanf("%d%d%d",&b,&c,&d); a=a*b*c*d; } printf("thanks!"); getche(); Entering numbers are a=1,b=2,c=3,d=4 b=3,c=4,d=-5 b=3,c=4,d=0

5 Answers   TCS,


void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..

32 Answers   College School Exams Tests, CTS, HCL, iGate, SmartData,


Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

2 Answers  


Why are memory errors hard to debug?

1 Answers  


how to convert decimal to hexadecimal without using arrays just loops

2 Answers  


I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00

3 Answers   UCB,


what is run time error?

7 Answers  


Categories