#import <Foundation/Foundation.h>
@interface calc:NSObject
{
int
a,b,res,ch;
}
-(void)calculate;
@end
@implementation calc
-(void)calculate;
{
printf("\n Menu:\n");
printf("\n\t(1)ADDITION");
printf("\n\t(2)SUBTRACTION");
printf("\n\t(3)MULTIPLICATION");
printf("\n\t(4)DIVISION");
printf("\n\t(0)Exit");
printf("\n Enter your
Choice:\n");
scanf("%d",&ch);
if (ch<=4 && ch>0)
{
printf("Enter two numbers:\n");
scanf("%d%d",&a,&b);
}
switch (ch)
{
case 1:
res=a+b;
printf("\n Addition:%d",res);
break;
case 2:
res=a-b;
printf("\n Subtraction:%d",res);
break;
case 3:
res=a*b;
printf("\n Multiplication:%d",res);
break;
case 4:
res=a/b;
printf("\n Division:%d",res);
break;
case 0:
printf("\n Choice Terminated");
exit(1);
break;
default:
printf("\n Invalid Choice..!!");
}
}
@end
int main (int argc,
const char
* argv[])
{
calc
*cal=[[calc alloc]init];
[cal calculate];
return 0;
}
No comments:
Post a Comment