Member Avatar for HASHMI007
#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;

}

Recommended Answers

All 3 Replies

struct rectInfo
{
int hight;
int width;
int area;
int parimeter;
};
void print(rectInfo r)
{
cout<<r.hight<<"	 "<<r.width<<"	 "<<r.area<<"	 "<<r.parimeter<<endl;
}

Structure doesn't have functions

Here's the information you need.

commented: excelent link +2
Member Avatar for HASHMI007

i do it. thnku very much

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.