Homework3-2 - scanf("%d", &b); /*computing...

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

View Full Document Right Arrow Icon
Homework #3 /* * Program hw3_2 * Written by Justin Waters * Inputs: an integer * Outputs: the integer in octal format * Description: The user enters a number and the program displays the number in octal format*/ #include <stdio.h> //printf, scanf defined #include <math.h> //math functions int main (void) { int b,c,d,e,f,g,h,i,j,k; //variables for octal computation /*gets a number from the user*/ printf("Enter a number between 0 and 32767:");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scanf("%d", &b); /*computing octal number from the user entered number*/ c = b / (8*8*8*8); d = b - (c*8*8*8*8); e = d / (8*8*8); f = d-(e*8*8*8); g = f / (8*8); h = f - (g*8*8); i = h / (8); j = h - (i*8); k = j / (1); /*displays computed octal number for the user*/ printf("In octal, your number is: %d%d%d%d%d ", c, e, g, i, k); return (0); }...
View Full Document

This note was uploaded on 08/06/2008 for the course EGR 261 taught by Professor Parikh during the Spring '08 term at Grand Valley State University.

Ask a homework question - tutors are online