Skip to content

Exercices préparatoires - Langage C Avancé

Exercice 1

Ecrire un programme qui:

  • Demande un nombre à l'utilisateur
  • Via une fonction, affiche la table de multiplication d'un nombre donné en paramètre
  • Affiche la table de multiplication de tous les nombres de 1 à 10
  • Affiche si le nombre est pair ou impair

Conversion python

Convertir les programmes python suivants en C:

Condition

python
x = 10
if x > 0:
    print("x est positif")
else:
    print("x est négatif")

Boucle

python
x = 10
for i in range(x):
    print(i)

Fonctions

python
def sum(a, b):
    return a + b

print(sum(1, 2))

Factorielle

python
def factorielle(n):
    if n == 0:
        return 1
    else:
        return n * factorielle(n - 1)

print(factorielle(5))