Average Grade2, Casting, Rectangle, Weather

This commit is contained in:
Out Of Ideas 2024-01-11 21:17:15 -06:00
parent 4c91ebba87
commit d703b371fb
8 changed files with 105 additions and 0 deletions

24
Average Grade2.c Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Average Grade\n");
int g1, g2, g3; /* Grade 1, Grade 2, and Grade 3 */
printf("Enter Your First Grade: ");
scanf("%d", &g1);
printf("Enter Your Second Grade: ");
scanf("%d", &g2);
printf("Enter Your Third Grade: ");
scanf("%d", &g3);
printf("Average Grade = %.2f\n", (g1 + g2 + g3) / 3.0); /* calculates and prints the avergage grade */
return 0;
}

BIN
Binaries/Average Grade2 Executable file

Binary file not shown.

BIN
Binaries/Casting Executable file

Binary file not shown.

BIN
Binaries/Rectangle2 Executable file

Binary file not shown.

BIN
Binaries/Weather Executable file

Binary file not shown.

13
Casting.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
int num1 = 5, num2 = 2;
float result = (float)num1 / num2;
printf("Result = %.2f\n", result);
return 0;
}

26
Rectangle2.c Normal file
View File

@ -0,0 +1,26 @@
/* Rectange Perimeter
*
* Rectangle Perimeter is a program that caulculates
* the perimeter of a rectangle based on the provided
* length and width.
*/
#include <stdio.h>
#include <stdlib.h>
int main() {
float l, w; /* Length and Width */
printf("Rectangle Peremiter\n");
printf("Length: ");
scanf("%f", &l);
printf("width: ");
scanf("%f", &w);
printf("Perimeter: %f\n", 2 * (l + w)); /* Peremiter = Length x Width */
return 0;
}

42
Weather.c Normal file
View File

@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdlib.h>
int main() {
int u, d, c; /* Temperature Unit and # of Dergreesn */
printf("Wheather\n");
printf("(1) Celcius -> Fahrenheit \n(2) Fahrenheit -> Celcius \n(1|2) ");
scanf("%d", &u);
/* Convert Celcius to Fahrenheit */
if (u == 1) {
printf("Celcius -> Fahrenheit\n");
printf("Enter temprature in Celcius: ");
scanf("%d", &d);
printf("Fahrenheit dergees = %.2f\n", d * 1.8 + 32); /* Fahrenheit Degrees */
}
/* Convert Fahrenheit to Celcius */
if (u == 2) {
printf("Fahrenheit -> Celcius\n");
printf("Enter temprature in Fahrenheit: ");
scanf("%d", &d);
printf("Celcius dergees = %.2f\n", (d - 32) / 1.8); /* Celcius Degrees */
}
if (u != 1 && u != 2) {
printf("Error: Invalid Argument\n");
exit(1);
}
return 0;
}