thx swagatob, i think i almost got it to work
edit:
oops, lol i dont know wut happen but it dont work again.
ill follow ur direction again swagatob, and im not sure is this wut u wanted me to do?
Code:
#include <stdio.h>
#include <conio.h>
int array[1000];
int getbinary(int binary);
main()
{
int temp;
int binary;
int power;
int decimal;
int cell;
cell = 0;
power = 1;
decimal = 0;
binary = getbinary(binary);
do{
temp = binary % 2;
if (temp==1)
{
array[cell] = power;
}
else
{
array[cell] = 0;
}
cell++;
power = power * 2;
binary = binary * .1;
} while(binary > 0);
for (cell=cell; cell>=0; cell--)
{
decimal = array[cell] + decimal;
}
printf("%d decimal\n", decimal);
getch();
}
int getbinary(int binary)
{
printf("Please enter binary: ");
scanf("%d", &binary);
while((binary != 0) && (binary != 1))
{
printf("Please enter binary 0's or 1's: ");
scanf("%d", &binary);
}
return binary;
}