CppBuzz.com
  
Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Home » Forum » x-Forum » Question

switch-arithmetic

switch-arithmetic

Posted by xzzjyn 2018-09-09 17:11:02

$a = 5;
switch($a)
{
case 4: echo "d";
break;
case 5: echo "e";
break;
case 6: echo "f";
break;
default:
 echo "non-def";
break;
}

C++ user image Patel Dhananjay answered 2018-09-17 20:17:34

/* Here is the code */

#include <stdio.h>

void sum(float a, float b){
float c = a+b;
printf("
 Addition is : %f", c);
}

void subs(float a, float b){
float c = a/b;
printf("
 Substraction is : %f", c);
}

void multi(float a, float b){
float c = a/b;
printf("
 Multiplication is : %f", c);
}

void divs(float a, float b){
float c = a/b;
printf("
 Division is : %f", c);
}

int main()
{
char choice;
    
printf("
 A-additiom-sum");
printf("
 S-subtraction-Difference");
printf("
 M-Multiplication-Product");
printf("
 D-Division-Quotient");

printf("
 Enter your choice : ");
scanf("%c",&choice);

float a, b, c;
printf("
 Enter a : "); 
scanf("%f", &a);
printf("
 Enter b : ");
scanf("%f", &b);

switch(choice){
    case 'A': sum(a, b); break;
    case 'B': subs(a, b); break;
    case 'C': multi(a, b); break;
    case 'D': divs(a, b); break;
    default: printf("
 Invalid Choice !!");
}

return 0;
}

C++ user image Admin answered 2018-09-17 20:26:18

<?php
$a=2;
$b=7;
$c=2;
$r=0;$q=0;
'Mult
$r=$a*$b;
echo $a,$b,$r;
'Sum
$r=$a+$b;
echo $a,$b,$r;
'Sub
$r=$a-$b;
echo $a,$b,$r;
'Div Qus Rem
$r=$a/$b;
echo $a,$b,$r;
$q=$a%$b;
echo $a,$b,$r;
?>

C++ user image pateldhananjay146 answered 2018-09-17 20:45:29

Your Answer




Ask New Question