# Problem You require an algorithm that will receive the length of the hypotenuse and one of the sides of a right triangle, and calculate the length of the.

## Presentation on theme: "Problem You require an algorithm that will receive the length of the hypotenuse and one of the sides of a right triangle, and calculate the length of the."— Presentation transcript:

Problem You require an algorithm that will receive the length of the hypotenuse and one of the sides of a right triangle, and calculate the length of the remaining side and the two acute angles in the triangle. You require an algorithm that will receive the length of the hypotenuse and one of the sides of a right triangle, and calculate the length of the remaining side and the two acute angles in the triangle.

Problem

Problem side1 side2 hyp angle1 angle2

Defining Diagram InputsProcessingOutput hypside1 Prompt for and get hyp and side1 Calculate side2 (Pythagorean theorem) Calculate angle1 and angle2 Display results side2angle1angle2

Calculate_Side_and_Angles Prompt user for hyp and side1 Get hyp and side1 side2 = hyp*hyp – side1*side1 side2 = SQRT(side2) angle1 = ARCSIN (side2/hyp) angle2 = 90 – angle1 Display side2, angle1 and angle2 END

Basic Elements of C++ Basic Elements of C++

# include # include using namespace std; int main() { cout<<“Hello world!”; cout<<“Hello world!”; return 0; return 0;} Preprocessor directive Function main Semicolons Curly braces

# include # include using namespace std; int main() { cout<<“Hello world!”; cout<<“Hello world!”; return 0; return 0;}

# include # include using namespace std; void main() { cout<<“Hello world!”; cout<<“Hello world!”; return; return;}

# include # include using namespace std; int main() { cout<<“Hello world!”; cout<<“Hello world!”; return 0; return 0;} /* This is our first C++ program Oh, how exciting!!!!! Oh, how exciting!!!!!*/ //this is our first function //this is preprocessor directive

Variables Identifiers can consist of Identifiers can consist of Letters Letters Digits (but cannot start with digits) Digits (but cannot start with digits) Underscore character Underscore character Identifiers are case sensitive. Identifiers should be self-explanatory.

price+tax price+tax My Number My Number costofthepurchase costofthepurchase _total_sum _total_sum one*two one*two pay\$ pay\$ xcsrtysb xcsrtysb Average_Age Average_Age 3rd_side 3rd_side Valid Identifiers?

C++ Data Types Simple Simple Structured Structured Pointers Pointers

Basic Data Types Integer - int Integer - int Floating point value – float, double Floating point value – float, double Character - char Character - char - bool Boolean - bool

1. 3.3 2. -4 3. 39.001 4. 0 5. 0.0 6. ‘d’ 7. ‘Bob’ 8. 9.0 9. +123 10. ‘ ’

Variable Declaration data-type variable-name, var-name… int num; float price1, price2; double average; char letter_grade; optional

Variable Initialization int a=3; //initialization int a=3; //initialization int a; int a; a=3; //assignment a=3; //assignment int a; int a; cin>>a; //input data cin>>a; //input data

# include # include using namespace std; int main() { int age; int age; cout<<“Enter your age”; cout<<“Enter your age”; cin >>age; cin >>age; cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/11/3269922/slides/slide_18.jpg", "name": "# include # include using namespace std; int main() { int age; int age; cout<< Enter your age ; cout<< Enter your age ; cin >>age; cin >>age; cout<>age; cin >>age; cout<

Calculate_Midpoint Prompt user for x1, y1, x2, y2 Get x1, y1, x2, y2 xm=(x1+x2)/2ym=(y1+y2)/2 Display xm and ym END

# include # include using namespace std; int main() { int x1, y1, x2, y2, xm, ym; cout<>x1 >>y1; cout<>x2 >>y2; xm=(x1+x2)/2;ym=(y1+y2)/2; cout< { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/11/3269922/slides/slide_20.jpg", "name": "# include # include using namespace std; int main() { int x1, y1, x2, y2, xm, ym; cout<>x1 >>y1; cout<>x2 >>y2; xm=(x1+x2)/2;ym=(y1+y2)/2; cout<>x1 >>y1; cout<>x2 >>y2; xm=(x1+x2)/2;ym=(y1+y2)/2; cout<

Review Declare an integer variable and initialize it to 8 Declare an integer variable and initialize it to 8 Give an example of preprocessor directive Give an example of preprocessor directive What is the name of the function that every C++ program must have? What is the name of the function that every C++ program must have? If A is initialized to 5 and B is initialized to 7 what are the values of A and B after the following assignment operation: If A is initialized to 5 and B is initialized to 7 what are the values of A and B after the following assignment operation: B=A; B=A; A = ________, B = _____________.

Review - identify the operation int num; int num; num = 5; num = 5; int num=5; int num=5; declaration assignment during declaration  initialization assignment

The grade distribution in a certain class is as follows: The grade distribution in a certain class is as follows: HW – 30% - 100 points max HW – 30% - 100 points max Tests – 45% - 100 points max Tests – 45% - 100 points max Labs - 25% - 100 points max Labs - 25% - 100 points max Write an algorithm that will receive the scores in each category of one student and display his final grade (out of 100%). Write an algorithm that will receive the scores in each category of one student and display his final grade (out of 100%).

Download ppt "Problem You require an algorithm that will receive the length of the hypotenuse and one of the sides of a right triangle, and calculate the length of the."

Similar presentations