Search This Blog

Sep 27, 2013

use of switch statement without loop in C

/*use of switch statement*/
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
int a,b,c,d,e,f,g,ch;
clrscr();
printf("Enter three numbers:");
scanf("%d%d%d",&a,&b,&c);
printf("\nMENU:\n1. Sumession\n2. Sum of square\n3. Sum ofcubes\n4. Product\n\n Enter Your Choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
d=a+b+c;
printf("The sumession is %d",d);
break;
case 2:
e=(a*a)+(b*b)+(c*c);
printf("The sum or square is %d",e);
break;
case 3:
f=pow(a,3)+pow(b,3)+pow(c,3);
printf("The sum of cube is %d",f);
break;
case 4:
g=a*b*c;
printf("The product is %d",g);
default:
printf("\nuser choice");
}
getch();
}

No comments:

Post a Comment