Exercise 2.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

Computer Science 1620 Math Library. Remember this program? suppose that I invest $25000 into a mutual fund that returns 8% per year. Write a program to.
Factorial Preparatory Exercise #include using namespace std; double fact(double); int fact(int); int main(void) { const int n=20; ofstream my_file("results.txt");
Vectors, lists and queues
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.
第三次小考. #include using namespace std; int aaa(int *ib,int a1,int a2) { int u,v; int m=(a1+a2)/2; if(a1==a2)return ib[a1]; u=aaa(ib,a1,m); cout
Tinaliah, S. Kom.. * * * * * * * * * * * * * * * * * #include using namespace std; void main () { for (int i = 1; i
Triana Elizabeth, S.Kom. #include using namespace std; void main () { for (int i = 1; i
Chapter 1: An Overview of Computers and Programming Languages
Perimeter and Area.
Pitch Perimeters WALT : calculate the perimeter of rectangles.
Perimeter and Area of Rectangles Kaitlyn Geary. Definitions Perimeter: the border or outside boundary of a two dimensional figure Area: the quantitative.
1 Section 3.1 introduction — an exploration into: Area and Perimeter Patterns Section 3.1 introduction — an exploration into: Area and Perimeter Patterns.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages Updated by: Dr\Ali-Alnajjar.
Programming is instructing a computer to perform a task for you with the help of a programming language.
Geometry Formulas Section Formulas  Perimeter of a Triangle:  Area of a rectangle:  Volume of a box:
PERIMETER Definition Add up all sides of the object 2 5 P = P = 14.
Solving systems of equations with 2 variables
Areas and Perimeter of Rectangles, Square, Triangles and Circles
Perimeter = 2*(length+width)
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
Distribute and Combine Like Terms Applications. What is the area of the following shape? 5 2x-3 1.
Basic Measurement.
PERIMETER Definition Add up all sides of the object 2 5 P = P = 14.
1 Original Source : and Problem and Problem Solving.ppt.
Lesson 5.6-Number Problems Obj: To solve # word problems.
Perimeter of Rectangles
Area of a quadrilateral is when you calculate Length X Width length width Area = length x width.
The length of a rectangle is 6 in. more than its width. The perimeter of the rectangle is 24 in. What is the length of the rectangle? What we know: Length.
Do Now: 1. Add: 2. Subtract: 3. Add: HW: p.56 # 14,16,18,20,24 p.75 # 6,10,12.
Toddrick’s Shape Scrapbook By:Toddrick Newton. The perimeter, P, of a rectangle is given by the formula P = 2(l + w) where l is the length width of the.
Year 7: Length and Area Perimeter The perimeter of a shape is the total distance around the edge of a shape. Perimeter is measured in cm A regular shape.
Example: cost of bananas at $0.19 each 0.19b Objective.
Perimeter & Area. Today’s Objectives:  Learn what it means to find perimeter and area.  Practice finding or estimating the perimeter and area.
A B The points on the coordinate plane below are three vertices of a rectangle. What are the coordinates of the fourth vertex? C.
How can you apply formulas for perimeter, circumference, and area to find and compare measures?
Notes Over 11.3 Using Direct and Inverse Variation When x is 4, y is 5. Find the equation that relates x and y in each case. Direct Variation Two quantities.
PERIMETERS What is the Perimeter of a shape. What is the Perimeter of this rectangle? What is the Perimeter of this rectangle? 5cm 15cm.
Q. What do we mean by finding the perimeter of a shape? Q. What strategies might you use for calculating the perimeter of a rectangle?
Perimeter, Area and Volume Presented by Bill Haining Functional Skills L1.
8th Grade Math Chapter 9a Review
Chapter 1: An Overview of Computers and Programming Languages
simplify radical expressions involving addition and subtraction.
Literacy Research Memory Skills Stretch Area
Standard Form A number expressed in standard form is a number written between 1 and 10 multiplied by 10 to an appropriate power. The use of standard form.
Chapter 1: An Overview of Computers and Programming Languages
Revision.
LI: to calculate the perimeter of regular polygons.
1 3 2 Maths 3:Perimeter, Area and Volume By: Bill Haining.
Obj: to use ratios to solve problems
Perimeter and Area of Rectangles on the Coordinate Plane
3 Solving Application Problems.
5 Chapter Chapter 2 Ratio and Proportion.
Objective - To identify how perimeter and area relate.
Use the substitution method to find all solutions of the system of equations {image} Choose the answer from the following: (10, 2) (2, 10) (5, - 2) ( -
Chapter 1: An Overview of Computers and Programming Languages
Starting Out with C++: From Control Structures through Objects
two-dimensional shape.
1-5 Geometric Formulas Polygons
King of the Mountain.
Chapter 1: An Overview of Computers and Programming Languages
2 types of scale factor problems
Area & Perimeter.
Adding and Subtracting Radicals
By- Sabrina,Julianna, and Killian
Introduction to Algorithms and Programming COMP151
Substitution 3..
Find the Perimeter.
Area and Volume How to … Calculate the area of a square or rectangle
The Pythagorean Theorem a2 + b2 = c2
Presentation transcript:

Exercise 2

Perimeter = 2*(length+width) Write C++ program to calculate the area and perimeter of ​​a rectangle. Note that the area of ​​the rectangle = length × width. Perimeter = 2*(length+width) #include <iostream> using namespace std; main() { int length, width; cout<<"length = "; cin>>length; cout<<"width = "; cin>>width; cout<<"perimeter = "<<2*(length+width)<<"\n"; cout<<"area = "<<length*width; }

Write C++ Program to calculate and print the area of a right-angled triangle . The base of the triangle = a The height of triangle= b Equation of area= (1/2)*a*b #include<iostream> using namespace std; int main() { int a,b; cout<<“Please enter the base of triangle \n”; cin>>a; cout<<“Please enter the height of triangle \n”; cin>>b; cout<<“Area of triangle= “<<(0.5)*a*b<<endl; return 0; }

Write c++ program that print the following form: \ Hello " C ' pp '   #include <iostream> using namespace std; void main() { cout<<" \\ Hello \" C \' pp \' "; }

Write a program to print your name in the first line in the left side, and the address in the middle of the third line, and nationality in the right side in the same line. #include <iostream> using namespace std; void main() { cout<<“Sara Mohamed \n\n\t\t\t"; cout<<“Al Kharj \t\t\t Saudi"; }

Write c++ program to accept integer number from user and then calculate the area of ​​a circle. Note: The equation of area circle = π * R2, where π is a constant value of approximately 3.14. perimeter = 2 * PI * R #include <iostream> Using namespace std; main() { float r, PI; PI = 3.1415926; cout<<“ Please enter radius of circle \n”; cin>>r; cout<<"area = "<< PI * r * r<<"\n"; cout<<" perimeter = "<< 2 * PI * r; }

Write a Program that does the following:- Promotes the user to enter 5 numbers. Print the Numbers. Print the sum and average of these five numbers. #include<iostream> using namespace std; int main() { int a,b,c,d,e,sum; float avg; cout<<"Enter the five numbers: \n"; cin>>a>>b>>c>>d>>e; sum = a + b + c + d + e; avg = sum/5; cout<<"the sum is "<<sum; cout<<" and the average is "<<avg<<endl; return 0; }  

Write c++ program to find the Perimeter and area of the square. The perimeter and area of the square are given by the following formula. Perimeter = sideLength* 4 Area = sideLength * sideLength Input square sideLength Processing Area= sideLength * sideLength Perimeter= sideLength*4 Output Print Out the perimeter and area #include <iostream> using namespace std; int main() { int length, width; cout<<“Please enter length of square \n”; cin>>length; cin>>width; cout<<“Area= “<<length*length<<endl; cout<<“Perimeter= “<<4*length<<endl; return 0; }

Write c++ program to print y If you now y is  (3x-7) if (x=-5) (5x2) if (x=2) or (x=5) (x-4x3) if (x=-4) or (x=4) #include <iostream.h> #include <math.h> main() { int x, y; cout<<"x = "; cin>>x; switch(x) { case -5: y=3*x-7; break;   case 2: case 5: y=5*pow(x,2); break; case -4: case 4: y=x-4*pow(x,3); } cout<<"y = "<< y;

Write a program that reads sides of the triangle (L1, L2, L3) and then a. Equilateral printed word in the case of equal ribs (L1 = L2 and L1 = L3 and L2 = L3) b. Isosceles printed word in the case of an isosceles (L1 = L2 or L1 = L3 or L2 = L3) c. Scalene printed word in the case of different ribs (L1!=L2 and L1!=L3 and L2!=L3) #include <iostream> #using namespace std; main() { float L1, L2, L3; cout<<"Enter L1, L2, L3 \n"; cin>>L1>>L2>>L3; if(L1==L2&&L1==L3&&L2==L3) cout<<"Equilateral"; else if(L1==L2||L1==L3||L2==L3) cout<<"Isosceles"; if(L1!=L2&&L1!=L3&&L2!=L3) cout<<"Scalene"; }

Write the output of (x) X = 3 * ( 8 - 6 ) + 4 *4

Write the output (x) X = 8 – 3 * 2 + 4 / 2 ^ 2 X = 8 – 3 * 2 + 4 / 4 X = 8 – 6 + 4 / 4 X = 8 – 6 + 1 X = 2 + 1 X = 3

X = ( 6 - 1 ) * 2 – 7 + 4 X = 5 * 2 – 7 + 4 X = 10 – 7 + 4 X = 3 + 4 Write the output (x) X = ( 6 - 1 ) * 2 – 7 + 4 X = 5 * 2 – 7 + 4 X = 10 – 7 + 4 X = 3 + 4 X = 7

Write the output (x) X = 5 + 2 * 4 / 2 X = 5 + 8 / 2 X = 5 + 4 X = 9

Write the output (x) X = ( 3 + 2 ) * 2 * 2 X = 5 * 2 * 2 X = 5 * 4 X = 20

What is the result of each compare A = 1 , B = 5 Result of compare example false A = B true B = A + 4 A < > 1 A < B A < 0 A < = 3 B < = 3 A > B A > 0 B > = 5 B > = 6

What is the result of each compare A = 1 , B = 2 , C = 3 Compare result example true A + 4 = B + C false A + B < C – 1 A + 3 < > B * C - 1 ( B + 3 ) * 2 > C * A - 1