Skip to content

Instantly share code, notes, and snippets.

@yesidays
Created July 16, 2012 10:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yesidays/3121953 to your computer and use it in GitHub Desktop.
Save yesidays/3121953 to your computer and use it in GitHub Desktop.
Decimal a binario
/* Conversión de número decimal a número binario */
#include <stdio.h>
int main() {
int n, c, k;
printf("Ingresa el número decimal: ");
scanf("%d", &n);
printf("%d en binario es: ", n);
for (c=7;c>=0;c--){
k = n>>c;
if (k&1){
printf("1");
}else {
printf("0");
}
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment