answersLogoWhite

0


Best Answer

// Addition Of Two Numbers Which r Taken From User!

/*Program Written by Maulin Thaker Ahmedabad;*/

#include

#include

void main()

{

float n1,n2,ans;

printf("Enter the First number\n");

scanf("%f",&n1);

printf("Enter the Second number\n");

scanf("%f",&n2);

ans=n1 + n2;

printf("Your Answer is -: %.3f",&ans);

}

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

public class Test {

public int add(int a, int b) {

return a + b;

}

public int sub(int a, int b){

return a - b;

}

public int mult(int a, int b){

return a * b;

}

public div(int a, int b){

return a/b;

}

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

# include < stdio.h >

# include < conio.h >

main ( )

{

int a,b,choice,result; /* Declare variables */

clrscr ( );

printf ( "1. Addition ");

printf ( "\n2. Subtraction ");

printf ( "\n3. Multiplication ");

printf ( "\n4. Division ");

printf( "\n Enter values of a,b=");

scanf ( %d%d", &a, &b); / * Input numbers variables */

printf ( " Enter your choice :-" );

scanf ( "%d" ,&choice); / * Input choice variable */

switch ( choice) /* Select any one choice */

{

Case 1:

result=a+b;

printf( " Addition = %d " ,result);

break;

Case 2:

result=a-b;

printf( "Subtraction = %d " ,result);

break;

Case 3:

result=a*b;

printf( "Multiplication = %d " ,result);

break;

Case 4:

result=a/b;

printf( " Division = %d " ,result);

break;

default:

printf ( " Your choice is wrong ");

}

getch( );

}

Output:

1. Addition

2. Subtraction

3. Multiplication

4. Division

Enter values of a,b= 8 4

Enter your choice :- 2

Subtraction =4

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

void main() { int op; float a; float b; float result; printf("Enter the Arithmetic Operation: \n 1 - Addition\n 2 - Subtraction\n 3 - Multiplication\n 4 - Division\n 0 - Exit"); scanf("%d", &op); printf("Enter first number: "); scanf("%f", &a); printf("Enter second number: "); scanf("%f", &b); switch (op) { case 1: result = a + b; break; case 2: result = a - b; break; case 3: result = a * b; break; case 4: if (b == 0) { printf("Cannot divide by zero.");

getch(); exit(1); } result = a / b; case 0: exit(1); default: { printf("invalid choice"); } printf("The result is: %f", result); getch(); }

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include<stdio.h>

#include<conio.h>

void main[ ]

{

int a,b,p;

clrscr[ ];

print f [" enter the value of a,b \n" ];

scan f ["%d%d,&a,&b];

s=a+b;

print f["the sum of %d%d and %d is %d a,b si];

}

d=a-b

print f ["the difference of %d %d,;s,d,a,b,d;];

p=a*b

["product of %d%d', a,b,p];

q=a/b

print f ["the coefficient of %d %d is %d''a,b\n"];

get ch[ ];

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

# include<stdio.h>

void main()

{

int a,add,sub,mul,div,x,y;

printf("enter a number\n :");

scanf("%d",&x);

printf("enter another number\n :");

scanf("%d",&y);

printf("1=addition")

printf("2=subtraction");

printf("3=multiplication");

printf("4=division");

printf("enter tour choice\n :");

scanf("%d",a);

switch(a)

{

case 1:

add=x+y;

printf("addition of %d and %d is =%d\n",x,y,add);

break;

case 2:

sub=x-y;

printf("subtraction of %d and %d is =%d\n",x,y,sub);

break;

case 3:

mul=x*y;

printf("multiplication of %d and %d is =%d\n",x,y,mul);

break;

case 4:

div=x/y;

printf("division of %d and %d is =%d\n",x,y,div);

break;

default :

printf("wrong choice");

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

#include<stdio.h>

#include<conio.h>

void main()

{

int n1, n2, ch ;

clrscr() ;

printf("Enter the first number : ") ;

scanf("%d", &n1) ;

printf("\nEnter the second number : ") ;

scanf("%d", &n2) ;

printf("\n[1] -> Addition ") ;

printf("\n[2] -> Subtraction ") ;

printf("\n[3] -> Multiplication ") ;

printf("\n[4] -> Division ") ;

printf("\n\nEnter your choice <1...4> : ") ;

scanf("%d", &ch) ;

switch(ch)

{

case 1 :

printf("\n%d + %d = %d", n1, n2, n1 + n2) ;

break ;

case 2 :

printf("\n%d - %d = %d", n1, n2, n1 - n2) ;

break ;

case 3 :

printf("\n%d * %d = %d", n1, n2, n1 * n2);

break ;

case 4 :

printf("\n%d / %d = %.2f", n1, n2, (float)n1 / n2);

break ;

default :

printf("\nInvalid choice");

break ;

}

getch();

}

email ThisBlogThis!Share to Twitter

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

A C program to divide, add, multiply and subtract two numbers; #include int main() { int first, second, add, subtract, multiply; float divide; printf("Enter two integersn"); scanf("%d%d", &first, &second); add = first + second; subtract = first - second; multiply = first * second; divide = first / (float)second; //typecasting printf("Sum = %dn",add); printf("Difference = %dn",subtract); printf("Multiplication = %dn",multiply); printf("Division = %.2fn",divide); return 0; }

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a c program to desine simple calculator using switch case?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you switch off a simple calculator?

by pressing the on/off button


Where is the Simply Switch program used?

Simple Switch is used to switch bank accounts from one bank to another. The switch is made in house and therefore causes the client less trouble. This is a new program placed on certain banks.


What is the simple switch?

a simple switch conduct current in both ways


What is simple switch?

a simple switch conduct current in both ways


How do you program vlans on a switch?

how to prgram vlans on a switch


How Replace ignition switch 02 impala?

how to program the new ign switch


How do you reset your graphing calculator?

-- There may be a small hole in the back of the calculator labeled "reset". If so, the calculator may be reset by carefully inserting the end of a straightened paper-clip a slight distance into the hole, and pressing the tiny switch located just inside the hole. -- If such a reset switch is not provided, then the calculator is reset by momentarily disconnecting the battery.


How do you program 2003 key switch?

program new keyswitch for 2003 odyssey


What kind of simple machine is a light switch?

The simple machine in a light switch is a "lever".


What is the control device for a simple circuit?

Switch


Is it hard to install a dimmer switch myself?

It is very simple to install a dimmer switch in place of a regular light switch.


Where can I find a bi-weekly mortgage calculator on the web?

This free online Biweekly Mortgage Payment Calculator will calculate the bi-weekly payment and the time and interest savings that will occur if you switch from .