# SOLVED:Lab 4

15.00 \$

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . ` docx` solution files instantly, after Payment

## Description

Overview:

This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, Analysis, , Design(program design, pseudocode), Test Plan, and implementation with C code. The example provided uses sequential, repetition statements and nested repetition statements.

Program Description:

This program will calculate the average of 10 positive integers. The program will ask the user to 10 integers. If any of the values entered is negative, a message will be displayed asking the user to enter a value greater than 0. The program will use a loop to input the data.

Analysis:

I will use sequential, selection and repetition programming statements.

The program will loop for 10 positive numbers, prompting the user to enter a number.

I will define three integer variables: count, value and sum. count will store how many times values greater than 0 are entered. value will store the input. Sum will store the sum of all 10 integers.

I will define one double number: avg. avg will store the average of the ten positive integers input.

The sum will be calculated by this formula: sum = sum + value For example, if the first value entered was 4 and second was 10: sum = sum + value = 0 + 4

sum = 4 + 10 = 14

Values and sum can be input and calculated within a repetition loop: while count <10

Input value

sum = sum + value End while

Avg can be calculated by: avg = value/count

A selection statement can be used inside the loop to make sure the input value is positive.

If value = 0 then count = count + 1 sum = sum + value

Else

input value End If

• lab4.docx