Tuesday, July 21, 2015

Calculator by structure

#include <stdio.h>
#include <stdlib.h>

struct calculator{

int add1,add2,sub1,sub2,div1,div2,mul1,mul2;


};

void display(struct calculator pos);


int main()
{
 struct calculator cal;

 printf("\nplease enter tow number for addition:");
 scanf("%d %d",&cal.add1,&cal.add2);

  printf("\nplease enter tow number for subtraction:");
 scanf("%d %d",&cal.sub1,&cal.sub2);

  printf("\nplease enter tow number for division:");
 scanf("%d %d",&cal.div1,&cal.div2);

  printf("\nplease enter tow number for multiplication:");
 scanf("%d %d",&cal.mul1,&cal.mul2);

 display(cal);


 return 0;

}

void display(struct calculator pos){


printf("\n-------------------------------------\n");
printf("THIS IS A SIMPLE CALCULATOR");
printf("\n-------------------------------------\n");

printf("ADDITION= %d\n",pos.add1+pos.add2);

printf("\nSUBTRACTION= %d\n",pos.sub1-pos.sub2);

printf("\nDIVISION= %d\n",pos.div1/pos.div2);

printf("\nMULTIPLICATION= %d\n",pos.mul1*pos.mul2);

printf("\n-------------------------------------\n");
printf("SOLVED");
printf("\n-------------------------------------\n");



}

1 comment: