11. Skills2 - C++ - Tutorial1

# 11. Skills2 - C++ - Tutorial1 - side2 =...

This preview shows pages 1–4. Sign up to view the full content.

Problem 1: Write a pseudo-code algorithm to get three numbers from the user, and give the user the average and the total of the three numbers. Solution Average of three numbers // this is the algorithm name // input three numbers // output two numbers Begin N1, N2,N3 are numbers Av , total are numbers Read N1,N2, N3 Total (N1+N2+N3) Av Total/3 Output Av, total End

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Problem 2: Write a pseudo-code algorithm to find the circumference of a triangle given the coordinates of each endpoint [for example, the circumference of a triangle at (0,0), (10,0) and (0,10) is 34.14]. Solution Circumference of a triangle // this is the name of the algorithm //input three points // output one number Begin A1, A2,B1,B2 C1,C2 are numbers Side1,side2,side3, Cir are numbers Read (A1,A2) Read(B1,B2) Read(C1,C2) // Find the length of each line of the triangle side1 squareroot[(A1-B1)squared + (A2-B2) squared)]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: side2 = squareroot[(A1-C1)squared + (A2-C2) squared)] side3 squareroot[(B1-C1)squared + (B2-C2) squared)] Cir side1 + side2 + side3 Output Cir End Problem 3: Write an algorithm to change a numeric grade to a pass/no pass grade Solution Pass/NoPass_Grade/ // input one number // output its conversion to grade Begin mark is number; grade is string; read (mark); if number ≥ 70 then grade “pass” otherwise grade “nopass” write (grade); End Problem 4: Write an algorithm to find the maximum of two numbers Solution Max // input two numbers // output their max Begin Nb1, Nb2, max are numbers; read (Nb1, Nb2); // process the max value If Nb1 ≥ Nb2 then max Nb1 Otherwise max Nb2 write ( max); End Problem 5 Covert each pseudo code above to flowchart...
View Full Document

{[ snackBarMessage ]}

### Page1 / 4

11. Skills2 - C++ - Tutorial1 - side2 =...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online