Good day,

Upon your request starting a new thread here for my next lab. Just wanted to thank you for the previous one I have finished and handed it in & also taught myself binary numbers.

Attached is Lab3

Thank you Bioman!

My lab was today 8-10 and I was able to complete it and hand it in!

Transcribed

LAB #3

Purpose:

The purpose of this lab is to learn how to write

a program to solve a stated problem, requiring

you to design the solution, use the editor to

enter the source program, eliminate the syntax

errors, and then test the program. This will be

the process followed in all the remaining labs.

Before the lab:

1. Read your notes concerning variable declarations and arithmetic

expressions.

2. Read your notes on the math library functions.

During the lab:

PART I: PROGRAMMING EXERCISES

Exercise #1:

a. Using Geany, write a C program that asks the user for four (4)

integer numbers and put those into 4 integer variables. Always

use a prompt to help guide the user. You can ask for all 4

numbers at once (like 'Enter 4 numbers:') or one by one.

b. Next, have your program produce and output the sum of those

four numbers. Be sure the output has a label which tells the user

what the output value represents. (eg: Sum of the four values is:

23).

c. Next have your program output the sum of the first two numbers

minus the sum of the last two.

d. Next have your program produce and output the sum of the

squares of the four numbers.

e. Next have your program produce and output the exact quotient (a

real number with a decimal point - a double) of the square root of

the sum of the squares of the numbers, divided by the sum of all

the numbers. eg for input values 3 4 5 6 this is 0.51 [square root

of (9+16+25+36) divided by 18]. Show the output with two

decimal digits of accuracy. Are you sure you got your answer

right? Try with a calculator and compare with your C program.

Exercise #2:

a. Using Geany, write a C program that creates a table of distance

equivalents in yards and miles for 100m, 200m, 400m, and

800m. You would input each value into a variable and then

convert it first to yards and then to miles by multiplying it by the

appropriate conversion factor. A meter is equivalent to 1.094

yards and 0.0006215 miles. Your program should right justify all

the numbers (see your printf notes from the lectures), aligning

them nicely in a column (table) form.

Exercise #3:

a. Using Geany, write a C program that calculates the volume of a

sphere. Look for the formula on the Internet and ask the user for

the required inputs (prompt the user clearly and label the

output).

Exercise #4:

a. Write and run in Geany a C program to find the third angle of a

triangle if two angles are given. No clue? Find the formula on the

Internet.

Exercise #5:

a. Using Geany, write a C program to compute the sum of the two

given integer values (ask the user for them). If the two values are

the same, display the triple of their sum. If they are not the

same, just display the sum.

Exercise #6:

a. Using Geany, write a C program that asks the user for 3 integer

numbers then displays these 3 numbers in descending order.

Assume all 3 numbers are different.

PART II: DISCOVERY ACTIVITIES

i. Can you explain why 3+5+8 divided by 3 doesn't give the correct

average of the numbers 3, 5, and 8?

ii. Using your text book, or an Internet search (do not ask friends or

TA) or simply by experimenting with Geany, explain in a few

sentences the differences between the division (/) and the

remainder (%) operators.

PART III: LAB REPORT SUBMISSION

1. Submit the .c files for programming exercises 1 to 6.

2. Submit the text file containing the answers to the 2 discovery

questions.

3. Submit on D2L/Brightspace under Lab #3. Submissions are due

at the end of the lab session. You must submit your work before

leaving the lab.

After the lab:

1. Review the steps you took to perform the various operations in

the lab.

Homework:

• On paper (no computer needed), do the following programming

(write the code by hand as you would on a test or an exam).

• Show your homework to your lab assistant at the beginning

of next week's lab.

• If you wish, you may try your solution with the computer to

see if you got the correct solution (no need to show the

computer version).

Last modified: January 06 2022 10:24:01.