TP 2 Atelier de Programmation 1 Correction 1
TP 2 Atelier de Programmation 1 Correction 1
TP 2 Atelier de Programmation 1 Correction 1
Exercice 1
1)
#include <stdio.h>
int main() {
scanf("%d", &n1);
scanf("%d", &n2);
} else {
return 0;
Exercice 2
#include <stdio.h>
int main() {
int N;
scanf("%d", &N);
if (N < Min) {
} else {
return 0;
Exercice 3
#include <stdio.h>
int main() {
int A, B;
scanf("%d", &A);
scanf("%d", &B);
} else if (A == 0 || B == 0) {
} else {
return 0;
Exercice 4
#include <stdio.h>
int main() {
int a, b, c, temp;
if (a < b) {
temp = a;
a = b;
b = temp;
if (b < c) {
temp = b;
b = c;
c = temp;
if (a < b) {
temp = a;
a = b;
b = temp;
printf("Les entiers triés par ordre décroissant sont : %d, %d, %d\n", a, b, c);
return 0;
Exercice 5
1) Avec Si .. Sinon si .. sinon
#include <stdio.h>
int main() {
char categorie;
int heuresSupplementaires;
float salaireFinal;
do{
scanf("%d", &heuresSupplementaires);
if (categorie == 'A') {
} else{
return 0;
2) Avec Switch
#include <stdio.h>
int main() {
char categorie;
int heuresSupplementaires;
float salaireFinal;
do{
scanf("%d", &heuresSupplementaires);
switch (categorie) {
return 0;
Exercice 6
#include <stdio.h>
int main() {
do {
scanf("%d", &heures);
do {
scanf("%d", &minutes);
do {
scanf("%d", &secondes);
secondes = 0;
minutes = 0;
/*
if (heures == 1)
th = '\0';
if (minutes == 1)
tm = '\0';
if (secondes == 1)
ts = '\0';
*/
return 0;
Exercice 7
#include <stdio.h>
int main() {
scanf("%d", &jour);
scanf("%d", &mois);
return 1 ;
if ((mois == 9 && jour >= 23) || (mois == 10) || (mois == 11) || (mois == 12 &&
jour <= 21)) {
printf("Saison d'automne\n");
} else if ((mois == 12 && jour >= 22) || (mois == 1) ||(mois == 3 && jour <= 19)
||
printf("Saison d'hiver\n");
else if ((mois == 3 && jour >= 20) || (mois == 4) || (mois == 5) || (mois == 6 &&
jour <= 20)) {
printf("Saison de printemps\n");
} else {
printf("Saison d'été\n");
return 0;
Exercice 8
1)
#include <stdio.h>
int main() {
char emplacement;
scanf("%f", &surface);
if (surface <= 0) {
prix_unitaire = 100;
prix_unitaire = 90;
prix_unitaire = 120;
prix_unitaire = 100;
prix_unitaire = 200;
prix_unitaire = 150;
} else {