রবিবার, ২৬ এপ্রিল, ২০১৫

A simple Calculator with C Programming

// Developed By Muhammad Rakib Hasan
// A simple Calculator with C Programming

#include<stdio.h>
int add(int num1,int num2);
float division(int num1,int num2);
int multiplication(int num1,int num2);
int substruction(int num1,int num2);

int main()
{
int a,b,output,subs;
float div,multi;
char ch;
printf("Please Enter +,-,* or / :");
scanf("%c",&ch);


if(ch=='+'){
printf("Please Enter First Number:");
scanf("%d",&a);
printf("Please Enter Second Number:");
scanf("%d",&b);
output=add(a,b);

printf("The sum of %d and %d is : %d\n",a,b,output);
}
else if(ch=='-'){
printf("Please Enter First Number:");
scanf("%d",&a);
printf("Please Enter Second Number:");
scanf("%d",&b);
subs=substruction(a,b);

printf("The substruction Value of %d and %d is: %d",a,b,subs);
}

else if(ch=='*'){
printf("Please Enter First Number:");
scanf("%d",&a);
printf("Please Enter Second Number:");
scanf("%d",&b);
multi=multiplication(a,b);
printf("The Multiplication Value of %d and %d is : %f",a,b,multi);
}
else if(ch=='/'){
printf("Please Enter First Number:");
scanf("%d",&a);
printf("Please Enter Second Number:");
scanf("%d",&b);
div=division(a,b);
printf("The Division Value of %d and %d is: %f",a,b,div);
}
else{
printf("Invalid input");
}
return 0;
}

int add(int a,int b){
int sum;
sum=a+b;
return sum;
}
int substruction(int a,int b){
int subs;
subs=a-b;
return subs;
}

int multiplication(int a,int b){
int multi;
multi=a*b;
return multi;
}
float division(int a,int b){
float div;
div=(float)a/b;
return div;

}

Result :

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন