Pages

write a program to find the average, sum, subtraction, product, remainder of given numners using switch statement (calculator)

Friday, 19 April 2013


#include<stdio.h>
#include<conio.h>


int main()
{
int a,b,c,d,e,f,g,h,i,j,subtract,sum,multiply,average,remainder,alpha;
    int floataverage=0; 
    
    printf("Enter any 10 numbers:\n");
    printf("Enter the operator 1,2,3,4\n");
  scanf("%d %d %d %d %d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
  printf("enter add for case 1\n enter sub for case 2\n enter multi for case 3\n enter avg for case 4\n enter remainder for case 5\n");
  scanf("%d",&alpha);


switch(alpha)
{
case 1:
sum=a+b+c+d+e+f+g+h+i+j;
printf("sum=%d\n",sum);
break;
case 2:
subtract=a-b-c-d-e-f-g-h-i-j;
printf("difference=%d\n",subtract);
break;
case 3:
multiply=a*b*c*d*e*f*g*h*i*j;
printf("product=%d\n",multiply);
break;
case 4:
average=(a+b+c+d+e+f+g+h+i+j)/10;
printf("avg=%d\n",average);
break;
case 5:
remainder=a%b;
printf("remainder=%d",remainder);
break;
default:
printf("invalid command");
}
getch();
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *