Ajout des TP
This commit is contained in:
9
BUT1/DEV1.1/Reels/extremites.c
Normal file
9
BUT1/DEV1.1/Reels/extremites.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int main(void)
|
||||
{
|
||||
printf("%f\n", +1.0 / 0.0);
|
||||
printf("%f\n", -1.0 / 0.0);
|
||||
printf("%f\n", -0.0 / 0.0);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
19
BUT1/DEV1.1/Reels/interets.c
Normal file
19
BUT1/DEV1.1/Reels/interets.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
float argent = 0;
|
||||
|
||||
printf("Combien d'euros souhaitez vous investir ?\n");
|
||||
|
||||
scanf("%f", &argent);
|
||||
|
||||
for (int i = 1; i < 8; i++)
|
||||
{
|
||||
|
||||
argent = argent + (argent * 0.04);
|
||||
printf("Année %d: %f\n", i, argent);
|
||||
}
|
||||
}
|
||||
12
BUT1/DEV1.1/Reels/operations.c
Normal file
12
BUT1/DEV1.1/Reels/operations.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int main(void)
|
||||
{
|
||||
printf("%f\n", 5.0 + 2.5);
|
||||
printf("%f\n", 5.0 - 2.5);
|
||||
printf("%f\n", 5.0 * 2.5);
|
||||
printf("%f\n", 5.0 / 2.5);
|
||||
// printf("%f\n", 5.0 % 2.5); // on ne peut pas effectuer de division euclidienne avec un nombre à virgule (un reél)
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
// DIVISION AVEC % SEULEMENT POUR DES ENTIERS (INT)
|
||||
7
BUT1/DEV1.1/Reels/poussieres.c
Normal file
7
BUT1/DEV1.1/Reels/poussieres.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main(void)
|
||||
{
|
||||
printf("%.15f\n", 12345.678910111213);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
7
BUT1/DEV1.1/Reels/r#U00e9ponses
Normal file
7
BUT1/DEV1.1/Reels/r#U00e9ponses
Normal file
@@ -0,0 +1,7 @@
|
||||
Réels :
|
||||
1) il faut mettre .12 devant le f pour avoir 12 chiffres après la virgule
|
||||
2) le % est un opérateur invalide car il est sûrement déjà utilisé au début pour le printf
|
||||
3) le programme affiche comme résultat :
|
||||
inf qui veut dire infinité
|
||||
-inf pareil mais avec un moins vu qu'on a divisé -1 par 0
|
||||
-nan signifie non défini car on ne peut pas diviser 0 par 0
|
||||
21
BUT1/DEV1.1/Reels/somme1.c
Normal file
21
BUT1/DEV1.1/Reels/somme1.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
float nombre1 = 0;
|
||||
float nombre2 = 0;
|
||||
float nombre3 = 0;
|
||||
float nombre4 = 0;
|
||||
float nombre5 = 0;
|
||||
|
||||
printf("Donne moi 5 nombres réels :\n");
|
||||
scanf("%f", &nombre1);
|
||||
scanf(" %f", &nombre2);
|
||||
scanf(" %f", &nombre3);
|
||||
scanf(" %f", &nombre4);
|
||||
scanf(" %f", &nombre5);
|
||||
|
||||
printf("%f\n ", nombre1 + nombre2 + nombre3 + nombre4 + nombre5);
|
||||
}
|
||||
19
BUT1/DEV1.1/Reels/somme2.c
Normal file
19
BUT1/DEV1.1/Reels/somme2.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
double somme = 0;
|
||||
double saisie = 0;
|
||||
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
printf("Séléctionnez le réel n°%d \n", i);
|
||||
scanf(" %lf", &saisie);
|
||||
|
||||
somme = somme + saisie;
|
||||
}
|
||||
|
||||
printf("Somme finale : %lf\n", somme);
|
||||
}
|
||||
22
BUT1/DEV1.1/Reels/telescopage.c
Normal file
22
BUT1/DEV1.1/Reels/telescopage.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
float nombre = 0;
|
||||
char caractere;
|
||||
printf("Entrez un nombre réel:\n");
|
||||
|
||||
scanf("%f", &nombre);
|
||||
printf("Nombre choisi : %e\n", nombre);
|
||||
|
||||
printf("Saisissez un caractère :\n");
|
||||
scanf(" %c", &caractere);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
|
||||
printf("Caractère choisi : %c, AFfichage numéro : %d\n", caractere, i + 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user