Addition, subtruction, division, multiplication using user define function in C

Bismillahir Rahmanir Rahim
Solution in C:

#include<stdio.h>
int add();
int sub();
float div();
int mul();
float average();
int big();
int small();
void main()
{
 int n,nn,count,c;
 main:
      printf("1.To Add two numbers.\n");
      printf("2.To Subtruct two numbers.\n");
      printf("3.To Divided two numbers.\n");
      printf("4.To Multiply two numbers.\n");
      printf("5.To average two numbers.\n");
      printf("6.Which one is big.\n");
      printf("7.Which one is small.\n");
      printf("Enter your choice.\t");
      scanf("%d",&n);
      switch(n)
      {
       case 1:
    printf("The sum of two numbers = %d\n",add());
      break;
       case 2:
    printf("The subtruct of two numbers = %d\n",sub());
    break;
       case 3:
    printf("The Division of two numbers = %2.2f\n",div());
    break;
       case 4:
    printf("The Multiplication of two numbers = %d\n",mul());
   break;
       case 5:
       printf("The average  is = %2.2f\n",average());
       break;
       case 6:
   printf("The big number is = %d\n",big());
   break;
        case 7:
   printf("The small number is = %d\n",small());
  break;
       default:
               printf("You choice nothing.\nThank you.\n");
      }
 printf("If you want to back to the main menu press 1.\n");
 scanf("%d",&nn);
 if(nn==1)
  goto main;
 else
  {
   printf("There is no way to back main menu.\n");
   printf("the program is closed.\tthank you.\n");
  }
   
}
int add()
{
 int a,b;
  printf("Enter two numbers.\n");
  scanf("%d%d",&a,&b);
 return (a+b);
}
int sub()
{
 int a,b;
  printf("Enter two numbers.\n");
  scanf("%d%d",&a,&b);
 return (a-b);
}
float div()
{
 int a,b;
  printf("Enter two numbers.\n");
  scanf("%d%d",&a,&b);
 return (a/b);
}
int mul()
{
 int a,b;
  printf("Enter two numbers.\n");
  scanf("%d%d",&a,&b);
 return (a*b);
}
float average()
{
 int a,b;
  printf("Enter two numbers.\n");
  scanf("%d%d",&a,&b);
  return ((a+b)/2);
}
int big()
{
 int a,b;
  printf("Enter two numbers.\n");
  scanf("%d%d",&a,&b);
 if(a>b)
  return a;
 else
  return b;
}
int small()
{
 int a,b;
  printf("Enter two numbers.\n");
  scanf("%d%d",&a,&b);
 if(a<b)
  return a;
 else
  return b;
}

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →