ajoutet1111.py

Created by joelkouakou2080

Created on March 13, 2024

1.19 KB


exo 1
DECLARE
    a NUMBER := 1;
    b NUMBER := 2;
    temp NUMBER;
BEGIN
    -- Affichage des valeurs initiales
    DBMS_OUTPUT.PUT_LINE('Avant permutation :');
    DBMS_OUTPUT.PUT_LINE('a = ' || a);
    DBMS_OUTPUT.PUT_LINE('b = ' || b);
    
    -- Permutation des valeurs
    temp := a;
    a := b;
    b := temp;
    
    -- Affichage des valeurs après permutation
    DBMS_OUTPUT.PUT_LINE('Après permutation :');
    DBMS_OUTPUT.PUT_LINE('a = ' || a);
    DBMS_OUTPUT.PUT_LINE('b = ' || b);
END;
/
---------------------------------
 exo 2
 DECLARE
    a NUMBER := 10;
    factorial NUMBER := 1;
BEGIN
    -- Calcul de la factorielle de a
    FOR i IN 1..a LOOP
        factorial := factorial * i;
    END LOOP;
    
    -- Affichage du résultat
    DBMS_OUTPUT.PUT_LINE('La factorielle de ' || a || ' est : ' || factorial);
END;
/
--------------------------------
exo3
DECLARE
    a NUMBER := 48;
    b NUMBER := 84;
    gcd NUMBER;
BEGIN
    -- Calcul du PGCD de a et b
    WHILE b != 0 LOOP
        gcd := b;
        b := MOD(a, b);
        a := gcd;
    END LOOP;
    
    -- Affichage du PGCD
    DBMS_OUTPUT.PUT_LINE('Le PGCD de ' || a || ' et ' || b || ' est : ' || gcd);
END;
/

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.