Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "my_header.h"
- int main()
- {
- do
- {
- printf("Kalkulator\n\nWybierz jedna z opcji\n\n");
- puts("1 Dodawanie");
- puts("2 Odejmowianie");
- puts("3 Mnozenie");
- puts("4 Dzielenie");
- puts("5 Potegowanie");
- puts("6 Zakoncz program");
- scanf("%c", &wyborProgramu);
- system("CLS");
- switch (wyborProgramu)
- {
- case '1':
- {
- printf("Ile liczb chcesz dodac?\n");
- scanf("%d", &iloscLiczb);
- /* alokacja pamieci dla tablicy liczb do dodawania*/
- arrayOfNumbers = (double*)calloc(iloscLiczb, sizeof (double));
- /* Przyjowanie liczb do tablicy*/
- for(int i = 0; i < iloscLiczb; i++)
- {
- printf("Liczba numer %d: ", i + 1);
- scanf("%lf", &arrayOfNumbers[i]);
- }
- /* Wyświetlenie tablicy*/
- for(int i = 0; i < iloscLiczb; i++)
- {
- printf("%.2lf\n", *arrayOfNumbers++);
- }
- //result = 3;
- /* Dodawanie, coś idzie nie tak :/ w ogóle nie przypisuje wyniku do zmiennej result. */
- for(int i = 0; i < iloscLiczb; i++)
- {
- result += *arrayOfNumbers++;
- printf("%.2lf %.2lf\n", result, *arrayOfNumbers++);
- }
- printf("Wynik to %.2lf\n", result );
- system("PAUSE");
- break;
- }
- case '2':
- {
- break;
- }
- case '3':
- {
- break;
- }
- case '4':
- {
- break;
- }
- case '5':
- {
- system("PAUSE");
- system("CLS");
- break;
- }
- default:
- //printf("NaN %i \n", wyborProgramu);
- break;
- }
- }while (wyborProgramu != '6');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement