Commit 479fbb083f66021428e4acc700714f7af28827e6
1 parent
edbb2f77ba
Exists in
master
HW3 Starter
Showing 8 changed files with 124 additions and 0 deletions Inline Diff
HW2/TestFolder/prob1
View file @
479fbb0
HW2/TestFolder/prob2
View file @
479fbb0
HW2/TestFolder/prob3
View file @
479fbb0
HW2/XYZ.c
View file @
479fbb0
File was created | 1 | /****************************************************************************** | ||
2 | * | |||
3 | * File name: template.c | |||
4 | * | |||
5 | * Author: John Jane Doe | |||
6 | * 012345678 | |||
7 | * jjdoe@ucsd.edu | |||
8 | * | |||
9 | * | |||
10 | * Lab #: | |||
11 | * Problem #: | |||
12 | * | |||
13 | * Submission Date: | |||
14 | * | |||
15 | ******************************************************************************/ | |||
16 | ||||
17 | ||||
18 | ||||
19 | /*----------------------------------------------------------------------------- | |||
20 | Include files: | |||
21 | -----------------------------------------------------------------------------*/ | |||
22 | ||||
23 | #include <stdio.h> | |||
24 | ||||
25 | ||||
26 | ||||
27 | /*============================================================================= | |||
28 | Constants and definitions: | |||
29 | =============================================================================*/ | |||
30 | ||||
31 | // put your #defines and typedefs here | |||
32 | ||||
33 | ||||
34 |
HW2/a.out
View file @
479fbb0
HW2/bmi.c
View file @
479fbb0
File was created | 1 | #include <stdio.h> | ||
2 | ||||
3 | int main() { | |||
4 | int weight = 0; | |||
5 | int feet = 0; | |||
6 | int inch = 0; | |||
7 | double height = 0.0; | |||
8 | double kilogram = 0.0; | |||
9 | double BMI = 0.0; | |||
10 | ||||
11 | printf("Your weight in pounds: "); | |||
12 | scanf("%d", &weight); | |||
13 | ||||
14 | printf("Your height in feet and inches, e.g. 5'10\": "); | |||
15 | scanf("%d'%d\"", &feet, &inch); | |||
16 | ||||
17 | height = (feet * 12 + inch) * 0.0254; | |||
18 | kilogram = weight / 2.20462; |
HW2/gpa.c
View file @
479fbb0
File was created | 1 | #include <stdio.h> | ||
2 | ||||
3 | int main(){ | |||
4 | double u1 = 0, | |||
5 | u2 = 0, | |||
6 | u3 = 0, | |||
7 | u4 = 0, | |||
8 | u5 = 0; | |||
9 | char g1 = ' ', | |||
10 | g2 = ' ', | |||
11 | g3 = ' ', | |||
12 | g4 = ' ', | |||
13 | g5 = ' '; | |||
14 | printf("Enter up to five course credits and grades (3A,4B,..): "); | |||
15 | int num = scanf("%lf%c,%lf%c,%lf%c,%lf%c,%lf%c", &u1, | |||
16 | &g1, &u2, &g2, &u3, &g3, &u4, &g4, &u5, &g5); | |||
17 | double top = | |||
18 | u1*(69-g1)+u2*(69-g2)+u3*(69-g3)+u4*(69-g4)+u5*(69-g5); | |||
19 | double bot = u1+u2+u3+u4+u5; | |||
20 | double gpa = top/bot; | |||
21 | printf("Your %d-course GPA is %.1f. Congratulations!\n", num/2, gpa); | |||
22 | return 0; |
HW2/table.c
View file @
479fbb0
File was created | 1 | #include <stdio.h> | ||
2 | ||||
3 | int main() { | |||
4 | ||||
5 | double number; | |||
6 | ||||
7 | printf("Enter a real number between 0 and 10: "); | |||
8 | scanf("%lf", &number); | |||
9 | double n2 = 2*number; | |||
10 | double n3 = 3*number; | |||
11 | double n4 = 4*number; | |||
12 | ||||
13 | printf("+--------+------+\n"); | |||
14 | printf("|multiple|number|\n"); | |||
15 | printf("+--------+------+\n"); | |||
16 | printf("| 1 |%6.4f|\n", number); | |||
17 | printf("| 2 |%6.3f|\n", n2); | |||
18 | printf("| 3 |%6.2f|\n", n3); |