I've been working on this for awhile now and I've decided to start over.
I'm trying to make a program where a user can enter 8 binary digits and have it output a number in decimal equal or less than 255. So as to not make the people weary of me here I've been on other forums and haven't had too much luck.
My idea is simple but I don't know how to translate it in c in my head.
First the user enters in a series of binary numbers and the program multiplies 128, 64, 32 by what ever digit corresponds to it. Then the program adds all the numbers up. Sounds simple I know! What I don't know is how to do my inputs.
It's kinda a mess. What I'm trying to do is have i represent each of the 8 bit digits and have a for statement increment i down the row of binary digits. Is their a simple way? I'm asking because I know the more experienced people can cut down on my programming time.Code:#include <stdio.h> #include "conio.h" int main() { int binary; int a,b,c,d,e,f,g,h; int pointer; int decimal; printf("Please enter in a b it binary number."); scanf("%d); for (i=0, i < 8, i++ ) { scanf("%d,i); printf("Your value in decimal is "%c".");



2Likes
LinkBack URL
About LinkBacks



The pointer is pointing down the row of binary numbers. The binary number is multiplied by the power of exponent from 7 to 0 and the answer is stored in storage_variable. The decimal value should be the sum of the storage variables... 