Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
CO Assignment 1 Question 1
#include <stdio.h> void change(char *data,int k){ int i,j,a[1000]; for(i=k-1;i>=0;i--){ //printf("%u\n",data[i]); int m=(int)data[i]; char byte[8]; byte[7]=(char)((m&1)+48); m=m>>1; byte[6]=(char)((m&1)+48); m=m>>1; byte[5]=(char)((m&1)+48); m=m>>1; byte[4]=(char)((m&1)+48); m=m>>1; byte[3]=(char)((m&1)+48); m=m>>1; byte[2]=(char)((m&1)+48); m=m>>1; byte[1]=(char)((m&1)+48); m=m>>1; byte[0]=(char)((m&1)+48); printf("%c%c%c%c%c%c%c%c ",byte[0],byte[1],byte[2],byte[3],byte[4],byte[5],byte[6],byte[7]); /*printf("%d",m&1); m=m>>1; printf("%d",m&1); m=m>>1; printf("%d",m&1); m= m>>1; printf("%d",m&1);*/ //printf("%s\n",byte); } } int main(int argc, char const *argv[]) { /* code */ int p=78738; int k=sizeof(p); char *data=&p; printf("Integer =%d\nBinary representation\n",p); change(data,k); printf("\n"); char c='a'; k=sizeof(c); char *dat=&c; printf("Char =%c\nBinary representation\n",c); change(dat,k); printf("\n"); float f=4.5; k=sizeof(f); char *fdata=&f; printf("Float =%f\nBinary representation\n",f); change(fdata,k); printf("\n"); double du=4.57465; k=sizeof(du); char *ddata=&du; printf("Double =%lf\nBinary representation\n",du); change(ddata,k); printf("\n"); return 0; }
run
|
edit
|
history
|
help
0
factorial
C_141210_Funciones
Finding the second largets value v0.6
FizzBuzz
Project 3 part 2 Book v0.6
Matrices de cadenas con *punteros
Shapes and such
SumIt
A_141124arrayRepetidos
Virtual table sketch