Advertisement
PiotrSzewczyk

Zad 6

Mar 24th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5. float iloraz(float a, float b)
  6. {
  7.     float c = a/b;
  8.     if(a<0 || b<0) return -2;
  9.     else if(b==0) return -1;
  10.     else return c;
  11. }
  12. int main(){
  13. float a, b;
  14. cout<<"Podaj liczbe naturalna: "<<endl;
  15. cin>>a;
  16. cout<<"Podaj druga liczbe naturalna: "<<endl;
  17. cin>>b;
  18. float d=iloraz(a,b);
  19. if(d==-1){
  20.     cout<<"Nie dziel przez zero"<<endl;
  21. }
  22. else if(d==-2){
  23.     cout<<"Podaj liczbe naturalna!"<<endl;
  24. }
  25. else{
  26.     cout<<"wynik to: "<<d<<endl;
  27. }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement