Ajout des TP
This commit is contained in:
32
BUT1/DEV1.1/Conditions/billevesees.c
Normal file
32
BUT1/DEV1.1/Conditions/billevesees.c
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int x = 3;
|
||||
|
||||
if (x == 2)
|
||||
{
|
||||
printf("x vaut 2\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("x est different de 2\n");
|
||||
}
|
||||
|
||||
printf("%d\n", x);
|
||||
|
||||
if (x == 0)
|
||||
{
|
||||
printf("x vaut 0\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("x est different de 0\n");
|
||||
}
|
||||
|
||||
printf("%d\n", x);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
31
BUT1/DEV1.1/Conditions/bissextile1.c
Normal file
31
BUT1/DEV1.1/Conditions/bissextile1.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main(void)
|
||||
{
|
||||
int annee;
|
||||
printf("Saisissez votre année : ");
|
||||
scanf("%d", &annee);
|
||||
if (annee % 4 == 0)
|
||||
{
|
||||
if (annee % 100 == 0)
|
||||
{
|
||||
if (annee % 400 == 0)
|
||||
{
|
||||
printf("L'année est bissextile\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("L'année est normale\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("L'année est bissextile\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("L'année est normale\n");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
17
BUT1/DEV1.1/Conditions/bissextile2.c
Normal file
17
BUT1/DEV1.1/Conditions/bissextile2.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main(void)
|
||||
{
|
||||
int annee;
|
||||
printf("Saisissez votre année : ");
|
||||
scanf("%d", &annee);
|
||||
if ((annee % 400 == 0) || ((annee % 100 != 0) && (annee % 4 == 0)))
|
||||
{
|
||||
printf("L'année est bissextile\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("L'année est normale\n");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
33
BUT1/DEV1.1/Conditions/ordre.c
Normal file
33
BUT1/DEV1.1/Conditions/ordre.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int num1, num2, num3;
|
||||
printf(" Entrez le 1er entier = ");
|
||||
scanf("%d", &num1);
|
||||
printf("\n Entrez le 2nd entier = ");
|
||||
scanf("%d", &num2);
|
||||
printf("\n Entrez le 3ème entier = ");
|
||||
scanf("%d", &num3);
|
||||
if (num1 > num2)
|
||||
{
|
||||
if (num1 > num3)
|
||||
{
|
||||
printf("\n Plus grand nombre est = %d \n", num1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n Plus grand nombre est= %d \n", num3);
|
||||
}
|
||||
}
|
||||
else if (num2 > num3)
|
||||
{
|
||||
printf("\n Plus grand nombre est= %d \n", num2);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n PLus grand nombre est= %d \n", num3);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
24
BUT1/DEV1.1/Conditions/produit.c
Normal file
24
BUT1/DEV1.1/Conditions/produit.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
float nombre = 0;
|
||||
float nombre2 = 0;
|
||||
|
||||
printf("Rentrez un réel :\n");
|
||||
scanf("%f", &nombre);
|
||||
printf("Rentrez le second réel :\n");
|
||||
scanf("%f", &nombre2);
|
||||
|
||||
if ((nombre < 0 && nombre2 < 0) || (nombre > 0 && nombre2 > 0))
|
||||
{
|
||||
|
||||
printf("Le résultat est positif");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Le résultat est négatif");
|
||||
}
|
||||
}
|
||||
21
BUT1/DEV1.1/Conditions/triple.c
Normal file
21
BUT1/DEV1.1/Conditions/triple.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int main(void)
|
||||
{
|
||||
int entier;
|
||||
int n;
|
||||
|
||||
printf("Entrez un entier naturel :\n");
|
||||
scanf("%d", &entier);
|
||||
|
||||
if (entier % 3 == 0)
|
||||
{
|
||||
printf("Multiple de 3 : %d\n", entier);
|
||||
}
|
||||
if (entier % 3 == 2)
|
||||
{
|
||||
printf("Multiple de 3 le plus proche : %d\n", entier + 1);
|
||||
}
|
||||
if (entier % 3 == 1)
|
||||
printf("Multiple de 3 : %d\n", entier - 1);
|
||||
}
|
||||
Reference in New Issue
Block a user