-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3421c6f
commit cb7c4d2
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Ex 1 | ||
Afficher le texte suivant dans la console. | ||
|
||
```console | ||
Bonjour | ||
Comment allez-vous ? | ||
``` | ||
|
||
# Ex 2 | ||
Écrire un programme qui affiche les valeurs des deux variables. | ||
|
||
Le résultat est affiché avec deux chiffres après la virgule. | ||
|
||
```CPP | ||
double val_d = 12.34; | ||
int cpt = 4; | ||
``` | ||
|
||
L'affichage : | ||
```console | ||
Affichage : | ||
Cpt : 4 / Val : 12.34 | ||
``` | ||
|
||
# Solutions | ||
## Ex 1 | ||
```cpp | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
cout<<"Bonjour" << endl << "Comment allez-vous ?"; | ||
return 0; | ||
} | ||
``` | ||
|
||
## Ex 2 | ||
```cpp | ||
#include <iostream> | ||
#include <iomanip> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
double val_d = 12.34; | ||
int cpt = 4; | ||
|
||
cout << "Affichage" << endl; | ||
cout << "Cpt : " << cpt << " / Val : " << fixed << setprecision(2) << val_d; | ||
return 0; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Ex 1 | ||
|
||
Écrire une fonction qui permet d'afficher le carré d'un `int` ou d'un `double`. | ||
|
||
|
||
# Ex 2 | ||
Quel est l'affichage du programme suivant ? | ||
|
||
```CPP | ||
#include <iostream> | ||
#include <iomanip> | ||
|
||
using namespace std; | ||
|
||
void func(int a){ | ||
cout << "Val_2 : " << a << endl; | ||
} | ||
|
||
void func(double a){ | ||
cout << "Val_3 : " << a << endl; | ||
} | ||
|
||
void func1(int a){ | ||
cout << "Val_1 : " << a << endl; | ||
func( (double)a ); | ||
} | ||
|
||
int main() | ||
{ | ||
double val_d = 2.0; | ||
int val_i = 5; | ||
|
||
func(val_d); | ||
|
||
func(val_i); | ||
|
||
func1(val_d); | ||
|
||
return 0; | ||
} | ||
``` | ||
# Solutions | ||
## Ex 1 | ||
```CPP | ||
#include <iostream> | ||
#include <iomanip> | ||
using namespace std; | ||
void aff(int a){ | ||
cout << "Res : " << a*a << endl; | ||
} | ||
void aff(double a){ | ||
cout << "Res : " << a*a << endl; | ||
} | ||
int main() | ||
{ | ||
double val_d = 2.3; | ||
int val_i = 5; | ||
aff(val_d); | ||
aff(val_i); | ||
return 0; | ||
} | ||
``` |