-
Notifications
You must be signed in to change notification settings - Fork 0
/
mt.c
42 lines (31 loc) · 695 Bytes
/
mt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
/***********************************************************
*
* The print_octal function takes an integer in decimal form
* and prints its octal form.
*/
void print_octal(int x)
{
if(x == 8){
printf("%d\n", x);
}
else{
x = x % 8;
print_octal(x);
}
}
/********************************************************************
*
* The main function prompts users for inputs.
* It calls print_octal to print its octal form.
*/
int main() {
int x;
printf("Enter a number between 0 and 32767:\n");
scanf("%d", &x);
//printf("In decimal, your nubmer is: %d",x);
printf("In octal, your nubmer is: ");
print_octal(x);
printf("\n");
return 0;
}