School-Coding-Cpp/funzioni/segno.cpp

25 lines
559 B
C++

/*
AUTORE: Manuel Vichi
Funzione segno
*/
#include <iostream>
#include <array>
#include <vector>
#include <cstdlib>
using namespace std;
signed int sign(int number) {
if (number > 0)
return +1;
else if (number == 0)
return 0;
else
return -1;
}
int main() {
signed int numero;
cout << "Inserisci un numero: ";
cin >> numero;
cout << endl << "Ricorda: La funzione segno stampa -1 se il numero e' negativo e +1 se il numero e' positivo." << endl << "Risultato della funzione segno: " << sign(numero) << endl;
return 0;
}