Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //zad3 kalkulator
- #include "stdafx.h"
- #include <conio.h>
- float Dodaj(float x, float y)
- {
- float wynik = x + y;
- return wynik;
- }
- float Odejmij(float x, float y)
- {
- float wynik = x - y;
- return wynik;
- }
- float Pomnoz(float x, float y)
- {
- float wynik = x * y;
- return wynik;
- }
- float Podziel(float x, float y)
- {
- float wynik = x / y;
- return wynik;
- }
- int main()
- {
- float x = 0, y = 0;
- char z = '+', next = 'x';
- do
- {
- printf("Podaj dwie liczby:\r\n");
- scanf_s("%f", &x);
- scanf_s("%f", &y);
- printf("Twoje liczby to: %f oraz %f.\r\n", x, y);
- printf("Podaj znak dzia�ania kt�e chcesz wykonac\r\n");
- z = _getch();
- float wynik;
- switch (z)
- {
- case '+':
- wynik = Dodaj(x, y);
- break;
- case '-':
- wynik = Odejmij(x, y);
- break;
- case '*':
- wynik = Pomnoz(x, y);
- break;
- case '/':
- wynik = Podziel(x, y);
- break;
- }
- printf("Wynik dzialania to %f\r\n", wynik);
- printf("Wpisz 1 zeby zaczac od poczatku, albo cokolwiek zeby wyjsc\r\n");
- next = _getch();
- }
- while (next == '1');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement