// this is a C program that read two numbers and calculate addition,subtraction ,multiplication division.
#include<stdio.h>
#include<conio.h>
    int a;
    float x,y;
void input();
void input()
{


    printf("Enter 1st number:");
     scanf("%f",&x);
    printf("Enter 2nd number:");
     scanf("%f",&y);
   }
void main()
{

    for(;;){
      clrscr();
    printf("Enter your choice:\n 1.Addition\n 2.Subtraction\n 3.Multiplication\n 4.Division\n 5.All\n\n Press 0 to exit\n\n");
     a=getch();
     if(a=='0')
     break;
     else
      switch(a)
   {
     case '1':
   {    printf("Addition :\n");
    input();
    printf("The addition of this numbers is %.2f .",x+y);
       getch();
      break;
   }
      case '2':
   {
    printf("Subtraction :\n");
    input();
    printf("The subtraction between this numbers is %.2f .",x-y);
       getch();
      break;
    }
      case '3':
    {
    printf("Multiplication:\n");
    input();
printf("The multiplication of this numbers is %.2f .",x*y);
    getch();
      break;
    }
     case '4':
    {
    printf("Division :\n");
    input();
    printf("The division of this numbers is %.2f .",x/y);
       getch();
      break;
    }
     case '5':
    {
    printf("All :\n");
    input();
    printf("The addition of this numbers is %.2f .",x+y);
    printf("\nThe subtraction between this numbers is %.2f .",x-y);
    printf("\nThe multiplication of this numbers is %.2f .",x*y);
    printf("\nThe division of this numbers is %.2f .",x/y);
       getch();
      break;
      }
      default :
    printf("Wrong Choice.Please try again with correct key numbers.");
      getch();
     break;
    }
    }

2 comments:

  1. Great Blog.... Very Good Blog for beginners of programming..........

    Keep up sharing and the good work... :)

    http://gamyguru.wordpress.com

    ReplyDelete

If you have any confusion, Please leave a comment. I will assist you. Do not include any URL in comments.

 
Top