Ajout des TP

This commit is contained in:
stiti
2024-02-01 13:55:03 +01:00
parent 4fe273c309
commit 113583b37a
228 changed files with 7094 additions and 0 deletions

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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");
}
}

View 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);
}