Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int enterNumber(double *px)
- {
- int t;
- do{
- printf("\nPodaj x: ");
- fflush(stdin);
- t=scanf("%lf",&(*px));
- if(t==0)
- return 0;
- }while(t==0);
- return 1;
- }
- double suma(double x, double y)
- {
- return x+y;
- }
- double roznica(double x, double y)
- {
- return x-y;
- }
- double iloczyn(double x, double y)
- {
- return x*y;
- }
- int iloraz(double x, double y, double *wynik)
- {
- if(y==0)
- return y;
- if(y!=0)
- {
- *wynik = x / y;
- return 1;
- }
- }
- int main(int argc, char *argv[]) {
- double k,x,y,wynik;
- //===========WSKAZNIKI=========
- double *px=&x;
- double *pwynik=&wynik;
- //===========WŁAŚCIWY PROGRAM==========
- printf("Witaj mr.Kalkulator");
- int powtorka;
- do{
- enterNumber(px);
- y=*px;
- enterNumber(px);
- printf("\nPodane liczby to: %lf, %lf", *px,y);
- k=suma(x,y);
- printf("\nSuma liczb to: %lf", k);
- k=roznica(x,y);
- printf("\nRoznica liczb to: %lf", k);
- k=iloczyn(x,y);
- printf("\nIloczyn liczb to: %lf", k);
- k=iloraz(x,y,pwynik);
- if(k==0){
- printf("Debilu nie dziel przez 0");
- }
- else
- printf("\nIloraz liczb to: %lf", *pwynik);
- printf("\nJeśli chcesz powtorki wciśnij 't' ");
- powtorka=0;
- scanf("%d",&powtorka);
- }while(powtorka==1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement