This commit is contained in:
“[JMF]” 2021-10-21 11:50:20 +02:00
parent d1b5108653
commit c46faaf4ca
22 changed files with 208 additions and 0 deletions

BIN
TP2/TD2 – Bases du C.pdf Normal file

Binary file not shown.

BIN
TP2/a.out Executable file

Binary file not shown.

19
TP2/exo2.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
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;
}

17
TP2/exo3.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
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") ;
}

11
TP2/pi.c Normal file
View File

@ -0,0 +1,11 @@
#include <stdio.h>
#include <math.h>
int main() {
const float pi = 3.141592653589793 ;
float pi_tan = acos(-1) ;
printf("%.16f %.16f %.16f \n",pi,pi_tan,M_PI);
}

BIN
TP2/printf Executable file

Binary file not shown.

12
TP2/rayon.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main() {
float rayon ;
float resultat ;
const float pi = 3.141592653589793 ;
rayon = 10;
resultat = pi * rayon * rayon ;
printf("resultat = %f\n",resultat);
}

14
TP2/rayon2.c Normal file
View File

@ -0,0 +1,14 @@
#include <stdio.h>
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);
}

Binary file not shown.

BIN
TP3/char Executable file

Binary file not shown.

18
TP3/char.c Normal file
View File

@ -0,0 +1,18 @@
#include <stdio.h>
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;
}

BIN
TP3/dowhile Executable file

Binary file not shown.

20
TP3/dowhile.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
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;
}

BIN
TP3/for Executable file

Binary file not shown.

16
TP3/for.c Normal file
View File

@ -0,0 +1,16 @@
#include <stdio.h>
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;
}

BIN
TP3/while Executable file

Binary file not shown.

19
TP3/while.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
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;
}

BIN
TP4/a.out Executable file

Binary file not shown.

19
TP4/char.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#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;
}

25
TP4/recherche.c Normal file
View File

@ -0,0 +1,25 @@
#include <stdio.h>
#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;
}

18
TP4/tableaux.c Normal file
View File

@ -0,0 +1,18 @@
#include <stdio.h>
#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;
}

BIN
TP5/a.out Executable file

Binary file not shown.