.
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -0,0 +1,17 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
double capital;
|
||||||
|
int annee;
|
||||||
|
|
||||||
|
printf("Montant a investir : ");
|
||||||
|
scanf("%lf", &capital);
|
||||||
|
|
||||||
|
for (annee = 1; annee <= 7; annee++) {
|
||||||
|
capital = capital * 1.04;
|
||||||
|
printf("Annee %d : %.2f €\n", annee, capital);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,24 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int annee;
|
||||||
|
|
||||||
|
printf("Veuillez entrer l'année actuelle : \n");
|
||||||
|
z
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,22 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int n, m, o;
|
||||||
|
int temp;
|
||||||
|
|
||||||
|
printf("Veuillez entrer une première valeur entière : ");
|
||||||
|
scanf("%i", &n);
|
||||||
|
printf("Veuillez entrer une deuxième valeur entière : ");
|
||||||
|
scanf("%i", &m);
|
||||||
|
printf("Veuillez entrer une troisième valeur entière : ");
|
||||||
|
scanf("%i", &o);
|
||||||
|
|
||||||
|
if (n > m) { temp = n; n = m; m = temp; }
|
||||||
|
if (n > o) { temp = n; n = o; o = temp; }
|
||||||
|
if (m > o) { temp = m; m = o; o = temp; }
|
||||||
|
|
||||||
|
printf("Les valeurs dans l'ordre croissant sont : %i < %i < %i\n", n, m, o);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,13 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int n;
|
||||||
|
|
||||||
|
printf("Veuillez entrer un entier naturel : \n");
|
||||||
|
scanf("%i", &n);
|
||||||
|
int reste = n % 3;
|
||||||
|
int plus_proche = (reste == 0) ? n : (reste == 1) ? n - 1 : n + 1;
|
||||||
|
printf("%i\n", plus_proche);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int n;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
printf("entrez un entier : ");
|
||||||
|
scanf("%d", &n);
|
||||||
|
|
||||||
|
for (i = 1; i <= 10; i++) {
|
||||||
|
printf("%3d x %2d = %4d\n", n, i, n * i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int dividende;
|
||||||
|
int diviseur;
|
||||||
|
int quotient;
|
||||||
|
int reste;
|
||||||
|
|
||||||
|
printf("Entrez une valeur >= 0 : ");
|
||||||
|
scanf("%d", ÷nde);
|
||||||
|
|
||||||
|
printf("Entrez une valeur > 0 : ");
|
||||||
|
scanf("%d", &diviseur);
|
||||||
|
|
||||||
|
quotient = 0;
|
||||||
|
reste = dividende;
|
||||||
|
|
||||||
|
while (reste >= diviseur) {
|
||||||
|
reste = reste - diviseur;
|
||||||
|
quotient++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("--> %d = %d x %d + %d\n", dividende, quotient, diviseur, reste);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,19 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
double capital;
|
||||||
|
int annee;
|
||||||
|
|
||||||
|
do {
|
||||||
|
printf("Montant a investir (entre 1000 et 50000) : ");
|
||||||
|
scanf("%lf", &capital);
|
||||||
|
} while (capital < 1000.0 || capital > 50000.0);
|
||||||
|
|
||||||
|
for (annee = 1; annee <= 7; annee++) {
|
||||||
|
capital = capital * 1.04;
|
||||||
|
printf("Annee %d : %.2f €\n", annee, capital);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,27 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int min;
|
||||||
|
int max;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
printf("Entrez deux entiers : ");
|
||||||
|
scanf("%d %d", &a, &b);
|
||||||
|
|
||||||
|
if (a < b) {
|
||||||
|
min = a;
|
||||||
|
max = b;
|
||||||
|
} else {
|
||||||
|
min = b;
|
||||||
|
max = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = min; i <= max; i++) {
|
||||||
|
printf("%d\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,29 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int min;
|
||||||
|
int max;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
printf("Entrez deux entiers : ");
|
||||||
|
scanf("%d %d", &a, &b);
|
||||||
|
|
||||||
|
if (a < b) {
|
||||||
|
min = a;
|
||||||
|
max = b;
|
||||||
|
} else {
|
||||||
|
min = b;
|
||||||
|
max = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = min;
|
||||||
|
while (i <= max) {
|
||||||
|
printf("%d\n", i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,29 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int min;
|
||||||
|
int max;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
printf("Entrez deux entiers : ");
|
||||||
|
scanf("%d %d", &a, &b);
|
||||||
|
|
||||||
|
if (a < b) {
|
||||||
|
min = a;
|
||||||
|
max = b;
|
||||||
|
} else {
|
||||||
|
min = b;
|
||||||
|
max = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = min;
|
||||||
|
do {
|
||||||
|
printf("%d\n", i);
|
||||||
|
i++;
|
||||||
|
} while (i <= max);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -0,0 +1,36 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int secret;
|
||||||
|
int proposition;
|
||||||
|
int tentative;
|
||||||
|
int trouve;
|
||||||
|
|
||||||
|
srand((unsigned int)time(NULL));
|
||||||
|
secret = rand() % 101;
|
||||||
|
|
||||||
|
trouve = 0;
|
||||||
|
|
||||||
|
for (tentative = 1; tentative <= 5 && !trouve; tentative++) {
|
||||||
|
printf("Tentative %d/5 (entre 0 et 100) : ", tentative);
|
||||||
|
scanf("%d", &proposition);
|
||||||
|
|
||||||
|
if (proposition < secret) {
|
||||||
|
printf("+\n");
|
||||||
|
} else if (proposition > secret) {
|
||||||
|
printf("-\n");
|
||||||
|
} else {
|
||||||
|
trouve = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trouve) {
|
||||||
|
printf("Gagne !\n");
|
||||||
|
} else {
|
||||||
|
printf("Perdu ! Le nombre etait %d.\n", secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,31 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int n;
|
||||||
|
int i;
|
||||||
|
int est_premier;
|
||||||
|
|
||||||
|
printf("Entrez un entier naturel : ");
|
||||||
|
scanf("%d", &n);
|
||||||
|
|
||||||
|
if (n < 2) {
|
||||||
|
est_premier = 0;
|
||||||
|
} else {
|
||||||
|
est_premier = 1;
|
||||||
|
for (i = 2; i * i <= n; i++) {
|
||||||
|
if (n % i == 0) {
|
||||||
|
est_premier = 0;
|
||||||
|
i = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (est_premier) {
|
||||||
|
printf("%d est un nombre premier.\n", n);
|
||||||
|
} else {
|
||||||
|
printf("%d n'est pas un nombre premier.\n", n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int v_lundi, v_mardi, v_mercredi, v_jeudi, v_vendredi;
|
||||||
|
int total;
|
||||||
|
double moyenne;
|
||||||
|
|
||||||
|
printf("Visiteurs lundi : ");
|
||||||
|
scanf("%d", &v_lundi);
|
||||||
|
|
||||||
|
printf("Visiteurs mardi : ");
|
||||||
|
scanf("%d", &v_mardi);
|
||||||
|
|
||||||
|
printf("Visiteurs mercredi : ");
|
||||||
|
scanf("%d", &v_mercredi);
|
||||||
|
|
||||||
|
printf("Visiteurs jeudi : ");
|
||||||
|
scanf("%d", &v_jeudi);
|
||||||
|
|
||||||
|
printf("Visiteurs vendredi : ");
|
||||||
|
scanf("%d", &v_vendredi);
|
||||||
|
|
||||||
|
total = v_lundi + v_mardi + v_mercredi + v_jeudi + v_vendredi;
|
||||||
|
moyenne = (double)total / 5;
|
||||||
|
|
||||||
|
printf("Nombre moyen de visiteurs par jour : %.2f\n", moyenne);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,17 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int valeur_int;
|
||||||
|
char valeur_char;
|
||||||
|
|
||||||
|
printf("Entrez un entier : ");
|
||||||
|
scanf("%d", &valeur_int);
|
||||||
|
|
||||||
|
valeur_char = (char)valeur_int;
|
||||||
|
|
||||||
|
printf("Valeur dans int : %d\n", valeur_int);
|
||||||
|
printf("Valeur dans char : %d (caractere : '%c')\n", valeur_char, valeur_char);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
printf("signed char : %hhd\n", 77);
|
||||||
|
printf("unsigned char : %hhu\n", 77);
|
||||||
|
printf("short int : %hd\n", 77);
|
||||||
|
printf("unsigned short int : %hu\n", 77);
|
||||||
|
printf("int : %d\n", 77);
|
||||||
|
printf("unsigned int : %u\n", 77U);
|
||||||
|
printf("long int : %ld\n", 77L);
|
||||||
|
printf("unsigned long int : %lu\n", 77UL);
|
||||||
|
printf("float : %.0f\n", 77.0f);
|
||||||
|
printf("double : %.0f\n", 77.0);
|
||||||
|
printf("long double : %.0Lf\n", 77.0L);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -0,0 +1,64 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int t1[2][5];
|
||||||
|
int t2[3][5];
|
||||||
|
int t3[5][5];
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
t1[i][j] = j + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
t2[i][j] = i * 5 + j + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
if (j < i) {
|
||||||
|
t3[i][j] = j + 1;
|
||||||
|
} else {
|
||||||
|
t3[i][j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Affichage*/
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
if (i < 2) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
printf("%2d ", t1[i][j]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" ");
|
||||||
|
|
||||||
|
if (i < 3) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
printf("%2d ", t2[i][j]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" ");
|
||||||
|
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
printf("%2d ", t3[i][j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,92 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
int t1[2][5];
|
||||||
|
int t2[3][5];
|
||||||
|
int t3[5][5];
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
/*Remplissage tableaux*/
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
t1[i][j] = j + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
t2[i][j] = i * 5 + j + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
if (j < i) {
|
||||||
|
t3[i][j] = j + 1;
|
||||||
|
} else {
|
||||||
|
t3[i][j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Affichage Normal*/
|
||||||
|
|
||||||
|
printf("\n Affichage normal \n");
|
||||||
|
|
||||||
|
printf("Tableau t1 :\n");
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
printf("%2d ", t1[i][j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nTableau t2 :\n");
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
printf("%2d ", t2[i][j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nTableau t3 :\n");
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
printf("%2d ", t3[i][j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Inversion ligne-colonne*/
|
||||||
|
|
||||||
|
printf("\n Inversion ligne-colonne \n");
|
||||||
|
|
||||||
|
printf("Tableau t1 inverse :\n");
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
printf("%2d ", t1[i][j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nTableau t2 inverse :\n");
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
printf("%2d ", t2[i][j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nTableau t3 inverse :\n");
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
printf("%2d ", t3[i][j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
@@ -1,10 +1,11 @@
|
|||||||
/* premier programme */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
printf("Hello World!\n");
|
double x;
|
||||||
|
double* ptr;
|
||||||
|
|
||||||
|
ptr = &x;
|
||||||
|
printf("%p\n", ptr);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user