made an Xcode Program and write a code into .h file
#import <Foundation/Foundation.h>
@interface rectangle:NSObject
{
float
l,w;
float
area,per;
}
-(void)calculate;
@end
@implementation rectangle
-(void)calculate;
{
printf("Enter the 2 values for each side of the
rectangle:\n");
scanf("%f%f",&l,&w);
area=l*w;
per=2*(l+w);
printf("Area of Rectangle is:%f\n",area);
printf("\nPerimeter of Rectangle is:%f",per);
}
@end
int main (int argc,
const char
* argv[])
{
rectangle
*rec=[[rectangle alloc]init];
[rec calculate];
return 0;
}
No comments:
Post a Comment