diff --git a/TP2/TD2 – Bases du C.pdf b/TP2/TD2 – Bases du C.pdf new file mode 100644 index 0000000..9b1868e Binary files /dev/null and b/TP2/TD2 – Bases du C.pdf differ diff --git a/TP2/a.out b/TP2/a.out new file mode 100755 index 0000000..8317acd Binary files /dev/null and b/TP2/a.out differ diff --git a/TP2/exo2.c b/TP2/exo2.c new file mode 100644 index 0000000..1cce3ba --- /dev/null +++ b/TP2/exo2.c @@ -0,0 +1,19 @@ +#include + +int main () { + int a = 5, b=10; + /********************************/ + /* avec une variable auxiliaire */ + /********************************/ + int aux=a; + a=b; + b=aux; + /********************************/ + /* sans variable auxiliaire */ + /********************************/ + a = 5, b=10; + a=a+b; + b=a-b; + a=a-b; + return 1; +} diff --git a/TP2/exo3.c b/TP2/exo3.c new file mode 100644 index 0000000..bf3fa16 --- /dev/null +++ b/TP2/exo3.c @@ -0,0 +1,17 @@ +#include +int main () { + float a, b, somme ; + + printf("Entrer le premier reel\n") ; + scanf("%f",&a) ; + printf("Entrer le second reel\n") ; + scanf("%f",&b) ; + + somme = a + b; + printf("a + b = %f\n", somme) ; + + printf("%f \n", a/b); + + if (somme < 0) printf("Somme < 0\n"); + else printf("Somme >= 0\n") ; +} diff --git a/TP2/pi.c b/TP2/pi.c new file mode 100644 index 0000000..ca10816 --- /dev/null +++ b/TP2/pi.c @@ -0,0 +1,11 @@ +#include +#include +int main() { + + const float pi = 3.141592653589793 ; + + float pi_tan = acos(-1) ; + + printf("%.16f %.16f %.16f \n",pi,pi_tan,M_PI); + +} diff --git a/TP2/printf b/TP2/printf new file mode 100755 index 0000000..8a93aa4 Binary files /dev/null and b/TP2/printf differ diff --git a/TP2/rayon.c b/TP2/rayon.c new file mode 100644 index 0000000..35abe38 --- /dev/null +++ b/TP2/rayon.c @@ -0,0 +1,12 @@ +#include +int main() { + float rayon ; + float resultat ; + const float pi = 3.141592653589793 ; + + rayon = 10; + resultat = pi * rayon * rayon ; + printf("resultat = %f\n",resultat); + +} + diff --git a/TP2/rayon2.c b/TP2/rayon2.c new file mode 100644 index 0000000..d9e4e1e --- /dev/null +++ b/TP2/rayon2.c @@ -0,0 +1,14 @@ +#include +int main() { + float x23 ; + float z_230 = 1e1; + float t_340 = 10.; + float oo=1./2*2*1/2; + const float loss = 6.28318/oo*1./4. ; + + + printf("%f %f %f \n",loss, z_230, t_340); + x23 = loss * z_230 * t_340; + printf("resultat = %f\n",x23); + +} diff --git a/TP3/TD3 – Tests et Boucles.pdf b/TP3/TD3 – Tests et Boucles.pdf new file mode 100644 index 0000000..e9e69a5 Binary files /dev/null and b/TP3/TD3 – Tests et Boucles.pdf differ diff --git a/TP3/char b/TP3/char new file mode 100755 index 0000000..a5c93d3 Binary files /dev/null and b/TP3/char differ diff --git a/TP3/char.c b/TP3/char.c new file mode 100644 index 0000000..2391410 --- /dev/null +++ b/TP3/char.c @@ -0,0 +1,18 @@ +#include + + +int main () +{ + char c1; + char c2; + char c3; + + scanf("%c",&c1); + scanf(" %c",&c2); + scanf("%c \n",&c3); + + printf("sortie %c %c \n",c1,c2); + + return 1; + +} diff --git a/TP3/dowhile b/TP3/dowhile new file mode 100755 index 0000000..5f6c95e Binary files /dev/null and b/TP3/dowhile differ diff --git a/TP3/dowhile.c b/TP3/dowhile.c new file mode 100644 index 0000000..a90ff9c --- /dev/null +++ b/TP3/dowhile.c @@ -0,0 +1,20 @@ +#include + +int main () { + int a = 5; + + int i = 6; + /********************************/ + /* avec une variable auxiliaire */ + /********************************/ + do { + printf("%d \n",i); + i = i + 1 ; + } while (i<= a) ; + /********************************/ + /* valeur à la fin */ + /********************************/ + printf("a la fin i vaut %d \n",i); + return 1; +} + diff --git a/TP3/for b/TP3/for new file mode 100755 index 0000000..8be60a3 Binary files /dev/null and b/TP3/for differ diff --git a/TP3/for.c b/TP3/for.c new file mode 100644 index 0000000..f315b50 --- /dev/null +++ b/TP3/for.c @@ -0,0 +1,16 @@ +#include + +int main () { + int max = 5; + + int i ; + + for (i =1 ; i<= max ; i++) { + printf("%d \n",i); + } + /********************************/ + /* valeur à la fin */ + /********************************/ + printf("après la boucle i vaut %d \n",i); + return 1; +} diff --git a/TP3/while b/TP3/while new file mode 100755 index 0000000..586e27f Binary files /dev/null and b/TP3/while differ diff --git a/TP3/while.c b/TP3/while.c new file mode 100644 index 0000000..525c7bd --- /dev/null +++ b/TP3/while.c @@ -0,0 +1,19 @@ +#include + +int main () { + + int max = 5; + int i = 1; + // i doit être initialisé avant le while + while ( i <= max) { + // faire tant que i est plus petit ou égal que 5 + printf("%d \n",i); + i = i + 1 ; // compteur, + } + /********************************/ + /* valeur à la fin */ + /********************************/ + + printf("après la boucle i vaut %d \n",i); // dernière valeur de i + return 1; +} diff --git a/TP4/a.out b/TP4/a.out new file mode 100755 index 0000000..f0b74ef Binary files /dev/null and b/TP4/a.out differ diff --git a/TP4/char.c b/TP4/char.c new file mode 100644 index 0000000..f0bf8bb --- /dev/null +++ b/TP4/char.c @@ -0,0 +1,19 @@ +#include + +#define N 5 +int main () { + +char hello[] = "hello"; + + int i ; + + for (i = 0 ; i< N ; i++) { + printf("%c",hello[i]); + } + printf("\n"); + + printf("%s\n",hello); + puts(hello); + + return 1; +} diff --git a/TP4/recherche.c b/TP4/recherche.c new file mode 100644 index 0000000..3e3e3ee --- /dev/null +++ b/TP4/recherche.c @@ -0,0 +1,25 @@ +#include + +#define N 10 + +int main () { + + int T[N] = {5,1,2,2,1,3,2,3,2,1}; + + int cible = 2 ; + + int compteur = 0 ; + + int i ; + + for (i = 0 ; i< N ; i++) { + if (T[i] == cible) + { + compteur = compteur + 1 ; + } + } + printf("Cible (%d) apparait %d fois \n",cible,compteur); + + + return 1; +} diff --git a/TP4/tableaux.c b/TP4/tableaux.c new file mode 100644 index 0000000..06dcd39 --- /dev/null +++ b/TP4/tableaux.c @@ -0,0 +1,18 @@ +#include + +#define N 10 +int main () { + + int T[N] = {5,1,2,2,1,3,2,3,2,1}; + + int tab[N]; + + int i ; + + for (i = 0 ; i< N ; i++) { + tab[i] = i*i; + printf("%d %d %d\n",i,T[i],tab[i]); + } + + return 1; +} diff --git a/TP5/a.out b/TP5/a.out new file mode 100755 index 0000000..3e71355 Binary files /dev/null and b/TP5/a.out differ