Pokaż wyniki od 1 do 6 z 6

Temat: [c] kalkulator

  1. #1

    Domyślnie [c] kalkulator

    i pytanie czemu odrazu program sie otwiera i zamyka co zrobiłem źle?
    #include <cstdio>

    using namespace std;

    int main() // Kalkulator by Troyaax 0.1
    {
    int a;
    int b;
    int c;
    int r;
    int h;
    int pi = 3.14;
    int liczba;
    int d;
    int e;
    int g;
    printf("Witaj w kalulatorze by Bartek 0.1, menu: \n");
    printf("1: Kwadrat\n");
    printf("2: Prostokat\n");
    printf("3: Trojkat \n");
    printf("4: Okrag \n");




    switch (liczba)

    { case 1: //Kwadrat
    printf("Podaj bok a\n");
    scanf("%d", &a);
    printf("Podaj bok b\n");
    scanf("%d", &b);
    printf("Pole to %d , a obwod to %d\n", a*a, 4*a;
    break;


    case 2: //Prostokat
    printf("Podaj bok a\n");
    scanf("%d", &a);
    printf("Podaj bok b\n");
    scanf("%d", &b);
    printf("Pole to %d, a obwod to %d\n", a*b, 2*a+2*b); break;


    case 3: //Trojkat
    printf("Podaj podstawe \n");
    scanf("%d", &a);
    printf("Podaj wysokosc \n");
    scanf("%d", &h);
    printf("Podaj ramie\n");
    scanf("%d", &d);
    printf("Podaj drugie ramie\n");
    scanf("%d", &e);
    printf("Pole to %d, a obwod to %d\n", a*0.5*h, a+d+e);
    case 4: // Okrag
    printf("Podaj promien\n");
    scanf("%d", &r);
    printf("Twoje pole to %d, a obwod to %d\n", 2*pi*r, pi*r^2);

    }

    return 0;
    }
    the quieter you become, the more you are able to hear

  2. #2

    Domyślnie

    Dodaj na końcu: getchar();

  3. #3

    Domyślnie

    Sugerowałbym sczytywać zmienną liczba przed switchem.

    switch (getch(liczba))

    oraz to co pisał Czepek
    This comment requires further study.

  4. #4

    Domyślnie

    Dodałem obie rzeczy, program się włącza pojawia się wybór menu etc, wybieram np 2 i program dead...
    the quieter you become, the more you are able to hear

  5. #5

    Domyślnie

    scanf("%d", &a);

    scanf("%d", a);
    This comment requires further study.

  6. #6

    Domyślnie

    działa, dzieki wielkie
    the quieter you become, the more you are able to hear

Uprawnienia

  • Nie możesz zakładać nowych tematów
  • Nie możesz pisać wiadomości
  • Nie możesz dodawać załączników
  • Nie możesz edytować swoich postów
  •