ConteD

Calcolo area e perimetro di un quadrilatero.

Oct 10th, 2015
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. int a=0;
  6. int p=0;
  7. int b;
  8. int h;
  9.  
  10. int main()
  11. {
  12. while (true)
  13. {
  14.  
  15. cout<<"Inserisci la base :";
  16. cin>>b;
  17. cout<<endl<< "Inserisci l'altezza :";
  18. cin>>h;
  19.   if(b==h)
  20.   {  cout<<endl<<"E' un quadrato : Si";
  21.      a = b*b;
  22.      p = b*4;
  23.   }
  24.   else
  25.   {  
  26.      cout<<endl<<"E' un quadrato : No";
  27.      a = (b*h);
  28.      p = (b+h)*2;
  29.   }
  30.  
  31. cout<<endl<<"L'area e' : "<<a;
  32. cout<<endl<<"Il perimetro e' : "<<p;
  33. cout <<endl<<endl<<endl;
  34. system ("pause");
  35. system ("cls");
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment