/* switch.c */ #include int main(void) { int operaatio,x; printf("Anna operaatio ja x:n arvo >"); scanf("%d %d",&operaatio,&x); switch (operaatio) { case 5: /* Operaatio 5 tekee saman kuin 4 */ case 4: x *= 2; break; /* 4 laskee x=x*2 */ case 3: x += 2; /* 3 laskee x=x+4 */ case 2: x++; /* 2 laskee x=x+2 */ case 1: x++; break; /* 1 laskee x=x+1 */ default: x=0; /* Muut nollaavat x:n */ } printf("Tulos operaatiolla %d on %d\n",operaatio,x); return 0; }