#include<iostream.h>
#include<stdlib.h>
struct rectInfo
{
int hight;
int width;
int area;
int parimeter;
void print()
{
cout<<hight<<" "<<width<<" "<<area<<" "<<parimeter<<endl;
}
};
void calArea(rectInfo *p,int n){
for(int i=0;i<n;i++){
p[i].area=p[i].hight*p[i].width;
p[i].parimeter=2*(p[i].hight +p[i].width);
}
}
void genData(rectInfo *p,int n)
{for(int i=0;i<n;i++){
int a=rand()%10;
int b=rand()%10;
p[i].hight=a;
p[i].width=b;
}
}
int main()
{int *y;
y=new int(2);
int n=20;
rectInfo *shape=new rectInfo[n];
genData(shape,n );
calArea(shape,n );
//shape[0].print();
cout<<"Hight"<<" Width"<<" Area"<<" Parimeter"<<endl;
for(int i=0;i<n;i++){
shape[i].print();
}
return 0;
}

HASHMI007
sam.bagga 0 Newbie Poster
arkoenig 340 Practically a Master Poster
NathanOliver commented: excelent link +2

HASHMI007
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.