Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1.  #include <iostream>
  2.  #include <string>
  3.  
  4.  using namespace std;
  5.  
  6.  bool eunquadratoperfetto(int numerodaverificare)
  7.  
  8.  {
  9.    int i = 1;
  10.    while (i * i < numerodaverificare) {
  11.      i++;
  12.    }
  13.    if (i * i == numerodaverificare) {
  14.      return true;
  15.    }
  16.  
  17.    return false;
  18.  }
  19.  int main() {
  20.    int input;
  21.    cout << "inserisci un numero: ";
  22.    cin >> input;
  23.    
  24.    while (input != 0) {
  25.      if (eunquadratoperfetto(input) == true) {
  26.        cout << " il valore inserito è un quadrato perfetto."<<endl;
  27.      } else {
  28.        cout << "il valore insserito non è un quadrato perfetto."<<endl;
  29.      }
  30.      
  31.      cout << "inserisci un numero: ";
  32.      cin >> input;
  33.    }
  34.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement