Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perimeter = 2*(length+width)

Similar presentations


Presentation on theme: "Perimeter = 2*(length+width)"— Presentation transcript:

1 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; Int main() { int length, width; cout<<"length = "; cin>>length; cout<<"width = "; cin>>width; cout<<"perimeter = "<<2*(length+width)<<"\n"; cout<<"area = "<<length*width; return 0; }

2 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; }

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

4 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"; }

5 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; Int main() { float r, PI; PI = ; cout<<“ Please enter radius of circle \n”; cin>>r; cout<<"area = "<< PI * r * r<<"\n"; cout<<" perimeter = "<< 2 * PI * r; return 0; }

6 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; }

7 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; }

8 Write the output of (x) X = 3 * ( ) + 4 *4 X = 3*2+4*4 X = 6+4*4 X = 6+16 X = 22

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

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

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

12 Write the output (x) X = ( ) * 2 * 2 X = 5 * 2 * 2 X = 10 * 2 X = 20

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

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


Download ppt "Perimeter = 2*(length+width)"

Similar presentations


Ads by Google