#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define HOURS_TO_MINUTES 60
#define DAY_TO_WEEKS 7
#define INCH_TO_CM 0.3937008
#define FEET_TO_CM 0.0328084
#define INCH_TO_FEET 12
void practice5_1(void)
{
int time;
int hours, minutes;
printf("please input time:");
scanf("%d", &time);
while(time > 10)
{
hours = time / HOURS_TO_MINUTES;
minutes = time % HOURS_TO_MINUTES;
printf("hours = %d, minutes = %d\n\n", hours, minutes);
printf("\n");
printf("please input time:");
scanf("%d", &time);
}
return;
}
void practice5_2(void)
{
const int bigger = 10;
int n, num;
printf("please input a number:");
scanf("%d", &num);
n = num;
while(n <= num+bigger)
{
printf("%d ", n);
n++;
}
printf("\n");
return;
}
void practice5_3(void)
{
int days;
int weeks, day;
printf("please input convert days:");
scanf("%d", &days);
while(days > 0)
{
weeks = days / DAY_TO_WEEKS;
day = days % DAY_TO_WEEKS;
printf("%d days are %d weeks, %d days\n\n", days, weeks, day);
printf("please input convert days:");
scanf("%d", &days);
}
return;
}
void practice5_4(void)
{
float height;
int feet;
float inch;
printf("Enter a height in centimeters: ");
scanf("%f", &height);
while(height > 0)
{
feet = (int)(height * FEET_TO_CM) ;
inch = (height * INCH_TO_CM) - (feet * INCH_TO_FEET);
printf("%.1f cm = %d feet, %.1f inches \n",
height, feet, inch);
printf("Enter a height in centimeters (<=0 to quit): ");
scanf("%f", &height);
}
printf("bye \n");
return;
}
void practice5_5(void)
{
int day, count, profits;
profits = 0;
count = 0;
printf("please input days:");
scanf("%d", &day);
while(count++ < day)
{
profits += count;
}
printf("your earn $%d\n", profits);
return;
}
void practice5_6(void)
{
int day, count, profits;
profits = 0;
count = 0;
printf("please input days:");
scanf("%d", &day);
while(count++ < day)
{
profits += count*count;
}
printf("your earn $%d\n", profits);
return;
}
double practice5_7(double x)
{
return x*x*x;
}
int main(void)
{
// practice5_1();
// practice5_2();
// practice5_3();
// practice5_4();
// practice5_5();
// practice5_6();
/* double num;
double cube;
printf("Please input a number and ");
printf("I will give you its cube: \n");
scanf("%lf", &num);
cube = practice5_7(num);
printf("The cube is : %lf: ", cube);
*/
// practice5_8();
// practice5_9();
return 0;
}