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

}

Edited by Ezzaral: Fixed code tags

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by HASHMI007
Featured Replies
  • [URL="http://www.daniweb.com/software-development/cpp/threads/78223"]Here[/URL]'s the information you need. Read More

0
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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.