lab 2 greg cal
Showing
with
187 additions
and
0 deletions
greg
0 → 100644
File added
greg.o
0 → 100644
File added
lab2/bin.c
0 → 100644
lab2/bin.o
0 → 100644
File added
lab2/greg.c
0 → 100644
lab2/number
0 → 100644
File added
lab2/number.c
0 → 100644
lab2/number.o
0 → 100644
File added
lab2/untitled
0 → 100644
File added
lab2/untitled.c
0 → 100644
lab2/untitled.o
0 → 100644
File added
-
Master
#include int main(){
int DefNum; int pow1; int pow2; pow1=0; pow2=1;
printf("Type your number such as 0, 1, 2, 3, 4....\n"); scanf("%d", &DefNum); if ((DefNum==1)||(DefNum==0)){ printf("The Binary representation is %d", DefNum); }else{ while(pow2=0){ if (pow2>DefNum){ printf("0"); pow1=pow1-1; pow2=pow2/2; }else{ printf("1"); DefNum=DefNum-pow2; pow1=pow1-1; pow2=pow2/2;
} }
} return 0; }
Please
register
or
sign in
to comment