Formulae:
- Area of Rectangle = Length * Breadth
- Area of Square = Side * Side
Calculate and print area and Circumference of circle
Code
#include<bits/stdc++.h>using namespace std;
void area_square(int s){ int area=s*s; //Calculating area cout<<"Area of Square is: "<<area<<endl; //Print area}
void area_rectangle(int l, int b){ int area=l*b; //Calculate area cout<<"Area of Rectangle is: "<<area<<endl; //print area}
int main(){
cout<<"Enter the side of square "<<endl; //Requesting side int side; //to store side cin>>side; //reading the side
cout<<"Enter length and breadth of rectangle "<<endl; //Requesting length & breadth int length,breadth; //to store length & breadth cin>>length>>breadth; //reading length & breadth
area_square(side); //calling area of square function
area_rectangle(length, breadth); //calling area of rectangle function
return 0;}
Calculate and print area and Circumference of circle
Code
#include<bits/stdc++.h>
using namespace std;
void area_square(int s){
int area=s*s; //Calculating area
cout<<"Area of Square is: "<<area<<endl; //Print area
}
void area_rectangle(int l, int b){
int area=l*b; //Calculate area
cout<<"Area of Rectangle is: "<<area<<endl; //print area
}
int main(){
cout<<"Enter the side of square "<<endl; //Requesting side
int side; //to store side
cin>>side; //reading the side
cout<<"Enter length and breadth of rectangle "<<endl; //Requesting length & breadth
int length,breadth; //to store length & breadth
cin>>length>>breadth; //reading length & breadth
area_square(side); //calling area of square function
area_rectangle(length, breadth); //calling area of rectangle function
return 0;
}
Output
Enter the side of square
4
Enter length and breadth of rectangle
2 3
Area of Square is: 16
Area of Rectangle is: 6
0 Comments