Given length L and breadth B of N rectangles. The task is to return maximum area of the rectangle using function & array
Answers
Answer:
Note: Language used : C++
Code:
#include<iostream>
using namespace std;
int p;
int area_rec(int a , int b) {
return a*b;
}
int max_area(int ar[]){
int big = ar[0] ;
for(int i = 0 ; i < p ;i++) {
if( big < ar[i+1] && i+1 <= p-1 ) {
big = ar[i+1] ;
}
}
return big;
}
int main() {
int L[10],B[10],area[10],r;
cout<<"Enter the number of rectangles: " ;
cin>>p;
for(int i = 0 ;i < p ;i++ ) {
cout<<"\nEnter length of Rectangle "<<i+1 <<" :" ;
cin>>L[i] ;
cout<<"\nEnter Breath of Rectangle "<<i+1 <<" :" ;
cin>>B[i] ;
cout<<"\n\n";
}
for(int r = 0 ;r < p ;r++ ) {
area[r] = area_rec(L[r],B[r]) ;
cout<<"\nThe area of Reactangle "<<r+1 <<" :" <<area[r] <<" sq units." ;
cout<<"\n\n";
}
cout<<"Maximum area is " <<max_area(area) <<" . ";
return 0;
}
If you have doubt then let me know and I will try to clarify your doubts.
Please follow me and mark this ans as Branliest answer.Thank you!