forgot to commit this
This commit is contained in:
14 files changed
+353
-20
No files matched your search
+31
-6
@@ -1,26 +1,51 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*
|
||||
* Course: COMP 2510
|
||||
* Assignment: Assignment 1
|
||||
* Name: Braeden Sowinski
|
||||
* Student ID: A01385066
|
||||
* Date: 2025-09-20
|
||||
* Description: Convert centimeters to feet and inches
|
||||
*/
|
||||
|
||||
|
||||
#define CENTIMETERS_PER_FOOT 30.48
|
||||
#define CENTIMETERS_PER_INCH 2.54
|
||||
#define INCHES_PER_FOOT 12
|
||||
|
||||
int main(void) {
|
||||
/**
|
||||
* main program entry
|
||||
*
|
||||
* continuously takes user input for a height
|
||||
* in centimeters and then converts that to
|
||||
* feet and inches with proper amount of decimal
|
||||
* points.
|
||||
*
|
||||
* Quits when a number less than or equal to 0
|
||||
* is inputed.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
float heightCm;
|
||||
int heightFeet;
|
||||
float heightInches;
|
||||
|
||||
do {
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
printf("Enter a height in centimeters (<=0 to quit): ");
|
||||
scanf("%f", &heightCm);
|
||||
|
||||
if (heightCm <= 0) {
|
||||
if (heightCm <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
heightFeet = (heightCm / CENTIMETERS_PER_FOOT);
|
||||
heightInches = (heightCm / CENTIMETERS_PER_INCH) -
|
||||
heightInches = (heightCm / CENTIMETERS_PER_INCH) -
|
||||
(INCHES_PER_FOOT * heightFeet);
|
||||
|
||||
printf(
|
||||
@@ -35,4 +60,4 @@ int main(void) {
|
||||
printf("Bye\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user