Thursday, 14 March 2013


#include<stdio.h>

void main()
{
int pilihan;
int x,y;

printf("1, Add\n");
printf("2, Subtract\n");
printf("3, Multiply\n");
printf("4, Divide\n");
printf("5, Reminder\n");

printf("Please select the operation (enter the number) as the above:");

scanf("%d" ,&pilihan);

switch (pilihan)
{
case 1:{
printf("Please enter 2 numbers (add operation) \n\n");
printf("First no:");
scanf("%d", &x);

printf("Second no:");
scanf("%d", &y);

printf("%d+%d= %d\n" ,x,y,x+y);

break;

  }

case 2:{

printf("Please enter 2 numbers (subtract operation) \n\n");
printf("First no:");
scanf("%d", &x);

printf("Second no:");
scanf("%d", &y);

printf("%d-%d= %d\n" ,x,y,x-y);


break;
  }

case 3:{

printf("Please enter 2 numbers (multiply operation) \n\n");
printf("First no:");
scanf("%d", &x);

printf("Second no:");
scanf("%d", &y);

printf("%d*%d= %d\n" ,x,y,x*y);

break;
  }
case 4:{

printf("Please enter 2 numbers (divide operation) \n\n");
printf("First no:");
scanf("%d", &x);

printf("Second no:");
scanf("%d", &y);

printf("%d/%d= %d\n" ,x,y,x/y);

break;
  }

case 5:{

printf("Please enter 2 numbers (add operation) \n\n");
printf("First no:");
scanf("%d", &x);

printf("Second no:");
scanf("%d", &y);

printf("%d bahgi %d berbaki  %d\n" ,x,y,x%y);

break;

default: printf("number is out of range. \n");

break;

  }
}

}

1 comment: