Untitled2

Untitled2 - return 0; } void dec_bin(int number) { int x,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//Convert decimal to binary / #include <stdio.h> # void dec_bin(int number); v int main(void) { int input = 0; printf("Digit (0-255): "); scanf("%d", &input); //(input >= 0) & (input < 256) ? dec_bin(input) : exit(1);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return 0; } void dec_bin(int number) { int x, y; x = y = 0; for(y = 7; y >= 0; y--) { x = number / (1 << y); number = number - x * (1 << y); printf("%d", x); } printf("\n"); }...
View Full Document

This note was uploaded on 02/14/2011 for the course CS 240 taught by Professor Rego during the Spring '08 term at Purdue.

Ask a homework question - tutors are online