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 43 44 45 46 47 48 49 50 51 52
|
#include <stdio.h>
#include <math.h>
void input(int *, int *);
void calculation(int, int, int*, int*);
void output(int, int, int, int);
int main()
{
{
int feet, inches, meters, centimeters;
input(&feet, &inches);
calculation(feet, inches, &meters, ¢imeters);
output(feet, inches, meters, centimeters);
return 0;
}
do
{
printf("To go again press Y\n"); // send back to start
printf("To exit program press N\n"); // exits program
scanf("%c", &choice);
}
while(choice != 'Y' && choice != 'y' && choice != 'N' && choice != 'n');
while(choice == 'Y' || choice == 'y');
return 0;
}
void input(int *f, int *i)
{
printf("Enter feet:\n");
scanf("%d", f);
printf("Enter inches:\n");
scanf("%d", i);
}
void calculation(int f, int i, int *m, int *c)
{
// calculation here to convert f and i to m and c
i = 12*f;
c = i*2.54;
m = c/100;
c - = m*100;
}
void output(int f, int i, int m, int c)
{
printf("%d feet and %d inches converted is %d meters and %d centimeters \n", f, i, m, c);
}
|