Download presentation

Presentation is loading. Please wait.

Published byBrooks Hucker Modified about 1 year ago

1
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.

2
Problem

3
Problem side1 side2 hyp angle1 angle2

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

5
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

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

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

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

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

10
# 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

11
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.

12
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?

13
C++ Data Types Simple Simple Structured Structured Pointers Pointers

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

15
‘d’ 7. ‘Bob’ ‘ ’

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

17
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

18
# include # include using namespace std; int main() { int age; int age; cout<<“Enter your age”; cout<<“Enter your age”; cin >>age; cin >>age; cout<

19
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

20
# include # include using namespace std; int main() { int x1, y1, x2, y2, xm, ym; cout<

21
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 = _____________.

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

23
The grade distribution in a certain class is as follows: The grade distribution in a certain class is as follows: HW – 30% points max HW – 30% points max Tests – 45% points max Tests – 45% points max Labs - 25% points max Labs - 25% 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%).

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google