Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- float add(float num1, float num2);
- float sub(float num1, float num2);
- float multiple(float num1, float num2);
- float division(float num1, float num2);
- int s_root(int num1);
- int power(int num1);
- int main()
- {
- float n1,n2,result ;
- printf("Enter Two Numbers ::\n ");
- scanf("%f",&n1);
- scanf("%f",&n2);
- int option ;
- printf("Enter 1 for Addition\nEnter 2 for subtraction \nEnter 3 for Multiplication\nEnter 4 for Division\nEnter 5 for square root \nEnter 6 for power\n");
- scanf("%d",&option);
- switch(option)
- {
- case 1:
- result=add(n1,n2);
- printf(" Addition is %f\n ", result );
- break ;
- case 2 :
- result=sub(n1,n2);
- printf("Subtraction is %f\n",result);
- break ;
- case 3 :
- result=multiple(n1,n2);
- printf("Multiplication is %f\n",result);
- break ;
- case 4 :
- result=division(n1,n2);
- printf("Division is %f",result);
- break ;
- case 5 :
- result=s_root(n1);
- printf("Square root is %f",result);
- break ;
- case 6 :
- result=power(n1);
- printf("Power is %f",result);
- break ; }
- }
- float add(float num1, float num2)
- {
- return num1+num2;
- }
- float sub(float num1, float num2)
- {
- return num1-num2;
- }
- float multiple(float num1, float num2)
- {
- return num1*num2;
- }
- float division(float num1, float num2)
- {
- return num1/num2;
- }
- int s_root(int num1)
- {
- return sqrt(num1);
- }
- int power(int num1)
- {
- return pow(num1,2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement