VaultBy ENSAMIENParrainage
C18 lines

tp2-ex4-q2.c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <math.h>

int main() {
    int n;
    printf("Entrez un entier n : ");
    scanf("%d", &n);
    if (n < 0) {
        printf("Un carre parfait ne peut pas être négatif.\n");
    }
    int racine = sqrt(n);
    if (racine * racine == n) {
        printf("%d est un carré parfait.\n", n);
    } else {
        printf("%d n'est pas un carré parfait.\n", n);
    }
    return 0;
}

    Type at least 2 letters. ↑ ↓ to move, Enter to open.