All pastes #790781 Raw Edit

FHDW / C Prog / Serie III / Aufg

public c v1 · immutable
·published 2007-11-20 16:21 UTC
rendered paste body
void aufgabe2(){    printf("# Aufgabe 2 \n");    printf("Programmieren Sie folgende Formeln: \n\n");    printf(" a) y = x^2 + 7x -1 \n");    printf(" b) y = sin(x) - cos(x) + 1/x \n");    printf(" c) y = (1 + 3x - 4x^2) / (7 - 4x (33.2 - x) ) \n");    printf(" d) Kaufmaenisches Runden - auf 3 kommastellen \n");    char menu;    printf("\nGeben Sie eines an: "); scanf("%c", &menu);        switch(menu){        case 'a':                int y;                int x;                printf("\nGeben Sie x als ganze Zahl vor: "); scanf("%i", &x);                y = (x*x) + (7*x) - 1;                                printf("Ihr Ergebnis: %i", y);        break;                case 'b':                double x2;                double y2;                printf("\nGeben Sie x als Komma- bzw. Ganzzahl vor: "); scanf("%lf", &x2);                y2 = sin(x2) - cos(x2) + (1/x2);                printf("Ihr Ergebnis: %lf", &y2);        break;                case 'c':                float x3;                float y3;                printf("\nGeben Sie x als Komma- bzw. Ganzzahl vor: "); scanf("%f", &x3);                y3 = (1 + (3*x3) - (4*x3*x3) ) / ( 7 - (4*x3*(33.2 - x3)) );                printf("Ihr Ergebnis: %1.2f", &y3);        break;                case 'd':                float x4;                float y4;                printf("\nGeben Sie eine Kommazahl zum kaufmaennischen Runden vor: "); scanf("%f", &x4);                y4 = ((x4*100 + 0.5)) / 100.0;                printf("Ihr Ergebnis: %f", &y4);        break;    }        getch();    }