Thursday, 2 August 2018

ALGORITHM OF CALCULATION OF ADDITION , SUB , MULTI , DIV OF A AND B IN C

Program To Input Two Number From User And Calculate Add,Sum,Multi,and Div Of The Number According To The Choice

/*program of menu driven program*//
# include <stdio.h>
void main ()
{
int a,b,c,choice ;
clrscr () ;
printf ("/n enter the first number :") ;
scanf ("%d", & a) ;
printf ("/n enter second number :");
scanf ("%d", & b) ;
printf ("/n you can perform the following operation :") ;
printf ("/n 1.addition :") ;
printf ("/n 2.subtraction :") ;
printf ("/n 3. multiplication :") ;
printf ("/n 4. division :") ;
printf ("/n enter your choice :") ;
scanf ("%d", & choice) ;
switch (choice)
{
case 1 ;
c= a+b ;
printf ("/n sum = %d", c) ;
break ;
case 2 ;
c= a-b ;
printf ("/n sub = %d", c) ;
break ;
case 3 ;
c= a*b ;
printf ("/n multi = %d", c) ;
break ;
case 4 ;
c= a\b ;
printf ("/n div = %d". c) ;
break ;
default :
printf ("/n invalid number :") ;
}
getch () ;
}
Output :: enter the first number :
                number is : 45
                enter second number 
                 number is : 35

c = 45 + 35 = 80   ( if choice is 1 )
c = 45 - 35 = 10     ( if choice is 2 )
c = 45 * 35 = 1575  ( if choice is 3 )
c = 45 / 35 = 1.2      ( if choice is 4 )

ALGORITHM : CALCULATE ADDITION , SUB , MULTI , DIV OF A AND B

This is program of having calculation according to the choice of user.

STEP 1. START.
STEP 2. INPUT A AND B AND THEN CHOICE.
STEP 3. [ CALCULATE ADDITION , SUB , MULTI , DIV OF A AND B ]
              
              1. IF ENTER CHOICE IS 1.
               2. PRINT " C = A + B ".
               3. IF ENTER CHOICE IS 2.
               4. PRINT " C = A - B ".
               5. IF ENTER CHOICE IS 3.
               6. PRINT " C = A * B ".
               7. IF ENTER CHOICE IS 4.
               8. PRINT " C = A / B ".

OTHERWISE

9. PRINT " INVALID CHOICE".
        { STEP 3 LOOP 9 IS END }
STEP 4. STOP




                











              


No comments:

Post a Comment

Featured post

Kalgudi Interview Round!!

Those who cleared the second round of kalgudi got an email from exceller to complete their Kalgudi Interview Round. So here we will discuss ...