Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ECE 175 Computer Programming for Engineering Applications

Fall 2022

Lab Assignment #2

Relevant Programming Concepts:

_ Conditional branching structures (if-then-else statements)

_ Loop structures

Problem 1 (14 Points): Triangles

Three lengths (A, B, C) can be formed into a triangle if three conditions are met A + B > C

B + C > A C + A > B

An isosceles triangle is a triangle that has two sides of equal length. Also, a right triangle is formed if any of the following is met

A2 + B2 = C2 B2 + C2 = A2 C2  + A2  = B2

Write a C program that asks the user to enter three lengths. Check to see if the three lengths can be formed into an isosceles triangle, right triangle, triangle, or no triangle at all. Report the results to the user.

Sample Code Execution: Bold text indicates information entered by the user Enter in three sides of a triangle A,B,C: 12.2 13.2 5

Sides A = 12.20, B = 13.20, C = 5.00 can be formed into a triangle

Enter in three sides of a triangle A,B,C: 0.2 12.2 13.2

Sides A = 0.20, B = 12.20, C = 13.20 cannot be formed into a triangle

Enter in three sides of a triangle A,B,C: 13.6 8 13.6

Sides A = 13.60, B = 8.00, C = 13.60 will form an isosceles triangle

Enter in three sides of a triangle A,B,C: 10.625 6.375 8.5

Sides A = 10.63, B = 6.38, C = 8.50 will form a right triangle

Enter in three sides of a triangle A,B,C: 5 2 2

Sides A = 5.00, B = 2.00, C = 2.00 cannot be formed into a triangle

Problem 2 (16 Points): For-Loop Develop a C program that

- Asks the user to enter a value of N


- Finds and displays the total number of values from 100-499 (inclusive) that are divisible by N.

- Finds and displays the sum of all positive numbers from 100-499 (inclusive) that are divisible by N

- Finds and displays the maximum of a positive number from 100-499 (inclusive) that are divisible by N

Sample Code Execution: Bold text indicates information entered by the user Enter value of N: 10

There are 40 values between 100-499 that are divisible by 10

Sum of numbers between 100-499 that are divisible by 10 is 11800 Maximum number between 100-499 that are divisible by 10 is 490

Enter value of N: 23

There are 17 values between 100-499 that are divisible by 23 Sum of numbers between 100-499 that are divisible by 23 is 5083

Maximum number between 100-499 that are divisible by 10 is 483

Enter value of N: 540

There are 0 values between 100-499 that are divisible by 540 Sum of numbers between 100-499 that are divisible by 540 is 0 NO Maximum number between 100-499 that are divisible by 540

More Test cases: N = 1 (answer: 400 values, sum = 119800, max = 499), N = 7 (answer: 57 values, sum = 17157, max = 497)