0% ont trouvé ce document utile (0 vote)
30 vues8 pages

CR - 2021 CPP

Le document est un contrôle de rattrapage pour un cours de physique à l'Université Cadi Ayyad, comprenant des questions sur la programmation en C++. Les étudiants doivent répondre à des questions en cochant la bonne réponse, avec des consignes spécifiques sur la manière de remplir le questionnaire. Chaque question évalue la compréhension des concepts de programmation et de logique.

Transféré par

a.loughzal6040
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
30 vues8 pages

CR - 2021 CPP

Le document est un contrôle de rattrapage pour un cours de physique à l'Université Cadi Ayyad, comprenant des questions sur la programmation en C++. Les étudiants doivent répondre à des questions en cochant la bonne réponse, avec des consignes spécifiques sur la manière de remplir le questionnaire. Chaque question évalue la compréhension des concepts de programmation et de logique.

Transféré par

a.loughzal6040
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

y +1/1/60+ y

Université Cadi Ayyad, Faculté des Science Semlalia, Département de Physique, Filière SMP–S4
Contrôle de rattrapage- EPR Théorique - Informatique, Durée : 1h30
Session Printemps 2021

0 1 2 3 4 5 6 7 8 9 ←− Codez votre N° Apogée en noircissant les cases correspondantes.


Chaque ligne correspond à un de chiffre du numéro apogée.
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 N° Apogée / Nom et Prénom
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9

Consignes
Vous avez droit à une et une seule copie. Lire attentivement l’énoncé de la question avant de NOIRCIR ( ) la bonne réponse. Utiliser un stylo bleu ou un stylo
noir. Une mauvaise réponse fait perdre des points. L’absence de réponse vaut 0 point. Pour des raisons d’organisation, nous avons omis volontairement dans chaque
question, l’entête suivante:
#include<iostream>
using namespace std;

------------------------------------------------ Début de l’epreuve -------------------------------------------------------------------------


Qu’affichent les programmes suivants après exécution ? Cochez la bonne réponse (Toutes les questions ont une seule bonne réponse).

Question 1 ( 1 pt ) Erreur 0 10 20 30
int main() 8.92 10 20 30 40
{
int k=1 , x=2 , y=5, z; 10.58 12.33 Question 10 ( 2 pt )
z = k++ ∗ x + y ; int main()
cout « ”z=”« z « endl; Question 6 ( 3 pt ) {
} int main() int A[5],i;
{ for(i=0;i<5;i++)
c=14 c=9 c=7 int a=10, b=20 ; {
int &x=a , &y=b ; A+i=i∗10 ;
Question 2 ( 2 pts ) x=a+y++ ; cout«∗(A+i)«”\t”;
int main() cout«a«”;”«b«endl; }
{ } }
int x=1, y=0 ; bool p ; 10 20 30 40 50
p = x++ && ++y ; Erreur 10 ; 20
cout«p«”\t”«x«”\t”«y ; 31 ; 21 Erreur
} 10 20 30 40
30 ; 20 30 ; 21
1 1 1 0 10 20 30 40
Question 7 ( 2 pt )
1 2 1 int main() Question 11 ( 3 pt )
{ int main()
0 2 1 int a=5, b=10 ; {
char c; c=’+’ ; int ∗a,∗b,∗maxi;
0 2 0 ∗a=5 , ∗b=10 ;
switch(c)
Question 3 ( 1 pt ) { if(∗a>∗b) maxi=b ;
int main() case ’-’ : cout«a-b«’\t’ ; else maxi=b ;
{ case ’+’ : cout«a+b«’\t’ ; cout«maxi«endl;
int x=2 , y=1 , z=3; case ’∗’ : cout«a∗b«’\t’ ; }
z = y =++x ; case ’/’ : cout«a/b«’\t’ ; On donne: &a=0x6ffe1c &b=0x6ffe18 &maxi=0x6ffe10
cout « x«”\t”« y «”\t”«z; } 10 N’affiche rien
} }
0x6ffe1c 0x6ffe18
3 3 3 -5 15 50 0.5 15 50 0.5
Question 12 ( 3 pt )
2 3 3 15 15 50 0 int main()
2 1 3 {
Question 8 ( 3 pt ) float a=2,b=4,x,h=a/b;
Question 4 ( 2 pt ) int main() for( ;a<b; )
int main() { {
{ int a=10,b=20,c=30; a+=h ; cout«a«”\t”;
int x=2, y=5, p=7 ; int &x=a, &y=b, x=a+y; }
p = (x++ , y++) ; int &x=c, ++c ; }
cout«p ; cout«a«”;”«b«”;”«c«endl;
} } Erreur
2 3 3.5 4
Erreur 30;20;30
5 2 6 3 boucle infini
30;20;31
2.5 3 3.5 4
Question 5 ( 3 pt ) 20;10;30 10;20;30
2 2.5 3 3.5
float devise (float euro, float dollar=0,float li_st=0)
{ Question 9 ( 2 pt ) Question 13 ( 2 pt )
float dirham=0; int main() int main()
dirham+=euro∗10.58; { {
dirham+=dollar∗8.92 ; int A[5]={10,20,30,40},i; int A[5]={10,20,30,40},i;
dirham+=li_st∗12.33 ; return dirham ; for(i=0;i<5;i++) for(i=0;i<5;i++)
} cout«A[i]«”\t” ; cout«∗A+i«”\t” ;
int main() } }
{ Erreur
cout«devise(1)«endl; 10 11 12 13 14
} 10 20 30 40 0 10 20 30 40 0

y y
y +1/2/59+ y

10 20 30 40 Question 21 ( 1 pt ) Question 27 ( 1 pt )
int main() int main()
Erreur { {
Question 14 ( 2 pts ) int a = 10; int a=5, ∗P ; P=&a ;
int main() do cout«a«”\t”«P«endl;
{ { a-- ; cout« ”\t”«a ; } }
int B[6]={5,1,4,8,3,2}, i ; while ( a >1); L’adresse de a est : 0x69fefc
for(i=1;i<=5;i++) } L’adresse de P est : 0x69fef8
cout«B[i]«”\t”; 5 0x69fefc
} 9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1 0 5 5
1 4 8 3
9 8 7 6 5 4 3 2 5 0x69fef8
1 4 8 3 2
Question 28 ( 2 pts )
1 4 8 Question 22 ( 1 pt ) int main()
int main() {
5 1 4 8 3 2 { int a= 2, b= 5 , ∗p1, ∗p2;
int a = 0; p1=&a ; p2=&b ; p1=p2;
Question 15 ( 2 pts ) while ( a < 8)
int main() cout «∗p1«”\t”«∗p2«endl;
{ cout« ”\t”«a; a++; } }
{ }
int B[6]={1,9,7,5,3,8}, i ;
for(i=5;i>=0;i=i-2) 5 2
0 1 2 3 4 5 6 7
cout«B[i]«”\t”; 5 5
} 1 2 3 4 5 6 7 8
2 5
0 1 2 3 4 5 6
8 5 9 2 2
8 3 5 Question 23 ( 1 pt )
void affiche(int a) ---------------- Début de l’exercice ---------------
1 7 3 Exercice
{
1 9 7 a=5;
} int main()
Question 16 ( 1 pt ) {
int main() int main()
{ int x = 5 , y = 3 , z=1 , a=7 ,∗p,k;
{ cout « &x « ’\t’ « &y « ’\t’ « &z « ’\t’ « &a «
int B[5]={1,3,5,7,9}; int a=2 ;
affiche(a); endl;
B++ ; cout«B ; for(p=&a,k=1;k<4;k++)
} cout«a«endl;
} {
∗p = 2 ∗ k + 1;
Erreur 1 0x22fef4 p++;
5 Erreur 2
}
Question 17 ( 1 pt ) cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl;
int main() Question 24 ( 3 pts )
void fonction (int a , int b) cout«p-&z«’\t’ « y-k «endl;
{ ∗p = 0 ;
int B[]={7,5,3,0,1} ; {
a--; ++b; ∗(p − 1) = 2;
cout«∗B-1; cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl;
} }
int main() p-=x;
Erreur { ∗p = a;
int a= 3 , b= 7; ∗(p − 1) = k ;
Valeur affichée est incorrecte fonction (a , b); cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl;
6 cout«a«’\t’«b; }
} Question 29 ( 2 pts )
Question 18 ( 2 pts ) 2 8
int main() 0x69fec8 0x69fecc 0x69fed0 0x69fed4
{ 0 0 0x69fed4 0x69fed0 0x69fecc 0x69fec8
int x=0 , y=2 ; 3 8
if (x>5 && (++y)<1 ) x=4; 0x69fed0 0x69fed4 0x69fecc 0x69fec8
else x=6; 3 7 0x69fed0 0x69fed0 0x69fec8 0x69fecc
cout«”y = ”«y«endl ; 2 7
} Question 30 ( 2 pts )
Question 25 ( 3 pt ) 5 7 3 5
y=1 y=3 y=2 y=4 int main()
{ 5 5 7 3
Question 19 ( 3 pts ) int a=3, b=2, c=1 ; 7 5 5 3
int main() c+= b ∗= ++a/=2 ;
cout«a«”\t”«b«”\t”«c«endl; ; 5 7 5 3
{
int a = 1; } Question 31 ( 2 pts )
do
{ a++; cout«”\t”«a ;} 2 2 3 2 3
while(a==2 && a<5); 3 2 1 2 2
}
4 8 9 -3 -2
Boucle infini 2 4 5 3 2
2 3 2 4 4 -3 3
1 2 3 4 2 -3
2 3 4 5 Question 26 ( 3 pts )
int main() Question 32 ( 2 pts )
2 { 0 2 5 3
int B[]={1,3,5,7,9},∗p1,∗p2;
Question 20 ( 2 pts ) p1=&B[1]; p2=p1+B[0]; 2 0 5 3
int main() cout« p1 «’\t’ « p2 «”\t”« ∗p2-∗p1 «endl;
{ 3 5 2 0
}
int a ; Dans les réponses proposées, les quantités p1 et p2 sont 0 2 3 5
for( a = 1 ; a<10 ; a++) ; exprimés sous forme de B+i au lieu de 0x…
cout« ”\t”«a ; Question 33 ( 2 pts )
} 3 7 2 4 3 5 3
1 2 3 4 5 6 7 8 9 B+1 B+2 3 4 3 3 5
9 3 5 2 3 4 3 5
1 2 3 4 5 6 7 8 9 10 B+1 B+2 2 3 4 5 3
10 B+1 B+3 4 ------------------ Fin de l’exercice --------------

y y
y +2/1/58+ y

Université Cadi Ayyad, Faculté des Science Semlalia, Département de Physique, Filière SMP–S4
Contrôle de rattrapage- EPR Théorique - Informatique, Durée : 1h30
Session Printemps 2021

0 1 2 3 4 5 6 7 8 9 ←− Codez votre N° Apogée en noircissant les cases correspondantes.


Chaque ligne correspond à un de chiffre du numéro apogée.
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 N° Apogée / Nom et Prénom
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9

Consignes
Vous avez droit à une et une seule copie. Lire attentivement l’énoncé de la question avant de NOIRCIR ( ) la bonne réponse. Utiliser un stylo bleu ou un stylo
noir. Une mauvaise réponse fait perdre des points. L’absence de réponse vaut 0 point. Pour des raisons d’organisation, nous avons omis volontairement dans chaque
question, l’entête suivante:
#include<iostream>
using namespace std;

------------------------------------------------ Début de l’epreuve -------------------------------------------------------------------------


Qu’affichent les programmes suivants après exécution ? Cochez la bonne réponse (Toutes les questions ont une seule bonne réponse).

Question 1 ( 2 pts ) Question 6 ( 2 pts ) 2 Erreur 5


int main() int main()
{ { Question 11 ( 3 pt )
int x=1, y=0 ; bool p ; int B[6]={5,1,4,8,3,2}, i ; int main()
p = x++ && ++y ; for(i=1;i<=5;i++) {
cout«p«”\t”«x«”\t”«y ; cout«B[i]«”\t”; int a=3, b=2, c=1 ;
} } c+= b ∗= ++a/=2 ;
cout«a«”\t”«b«”\t”«c«endl; ;
0 2 0 5 1 4 8 3 2 }
1 2 1 1 4 8 3 3 2 1
0 2 1 1 4 8 3 2 2 2 3
1 4 8 2 4 4
1 1 1
Question 7 ( 2 pts ) 2 4 5
Question 2 ( 1 pt ) int main()
int main() { 4 8 9
{ int B[6]={1,9,7,5,3,8}, i ; Question 12 ( 3 pts )
int k=1 , x=2 , y=5, z; for(i=5;i>=0;i=i-2) void fonction (int a , int b)
z = k++ ∗ x + y ; cout«B[i]«”\t”; {
cout « ”z=”« z « endl; } a--; ++b;
} }
8 3 5 int main()
c=9 c=7 c=14 1 9 7 {
int a= 3 , b= 7;
1 7 3 fonction (a , b);
Question 3 ( 1 pt )
int main() 8 5 9 cout«a«’\t’«b;
{ }
int x=2 , y=1 , z=3; Question 8 ( 1 pt )
z = y =++x ; int main() 3 8
cout « x«”\t”« y «”\t”«z; { 2 7
} int B[]={7,5,3,0,1} ;
cout«∗B-1; 3 7
2 3 3 } 2 8
3 3 3 6 0 0
2 1 3 Erreur
Question 13 ( 3 pt )
Valeur affichée est incorrecte float devise (float euro, float dollar=0,float li_st=0)
Question 4 ( 2 pt )
int main() Question 9 ( 1 pt ) {
{ int main() float dirham=0;
int x=2, y=5, p=7 ; { dirham+=euro∗10.58;
p = (x++ , y++) ; int B[5]={1,3,5,7,9}; dirham+=dollar∗8.92 ;
cout«p ; B++ ; cout«B ; dirham+=li_st∗12.33 ; return dirham ;
} } }
int main()
Erreur 1 0x22fef4 {
5 3 2 6 cout«devise(1)«endl;
}
Question 10 ( 1 pt )
Question 5 ( 2 pts ) void affiche(int a) 0 8.92
int main() {
{ Erreur
a=5;
int x=0 , y=2 ; } 10.58 12.33
if (x>5 && (++y)<1 ) x=4; int main()
else x=6; { Question 14 ( 3 pt )
cout«”y = ”«y«endl ; int a=2 ; int main()
} affiche(a); {
cout«a«endl; int ∗a,∗b,∗maxi;
y=1 y=4 y=2 y=3 } ∗a=5 , ∗b=10 ;

y y
y +2/2/57+ y

if(∗a>∗b) maxi=b ; 10 20 30 40 Question 26 ( 2 pts )


else maxi=b ; Erreur
cout«maxi«endl; 5 7 3 5
} 10 20 30 40 50 5 7 5 3
On donne: &a=0x6ffe1c &b=0x6ffe18 &maxi=0x6ffe10 0 10 20 30 40
7 5 5 3
10 0x6ffe18 Question 21 ( 3 pt )
int main() 5 5 7 3
N’affiche rien 0x6ffe1c { Question 27 ( 2 pts )
Question 15 ( 2 pt ) int a=10, b=20 ;
int main() int &x=a , &y=b ; 2 3
{ x=a+y++ ;
cout«a«”;”«b«endl; -3 3
int A[5]={10,20,30,40},i;
for(i=0;i<5;i++) } 3 2
cout«A[i]«”\t” ; 30 ; 20 10 ; 20 2 -3
}
Erreur -3 -2
Erreur
31 ; 21 30 ; 21 2 2
10 20 30 40 0
Question 22 ( 2 pts ) Question 28 ( 2 pts )
10 20 30 40
int main()
10 20 30 { 0 2 5 3
Question 16 ( 3 pt ) int a= 2, b= 5 , ∗p1, ∗p2; 0 2 3 5
int main() p1=&a ; p2=&b ; p1=p2;
cout «∗p1«”\t”«∗p2«endl; 3 5 2 0
{
float a=2,b=4,x,h=a/b; } 2 0 5 3
for( ;a<b; ) 2 2
{ Question 29 ( 2 pts )
a+=h ; cout«a«”\t”; 5 2
4 3 3 5
} 5 5
} 3 4 5 3
2 5
2.5 3 3.5 4 4 3 5 3
Question 23 ( 1 pt )
2 2.5 3 3.5 int main() 3 4 3 5
2 3 3.5 4 { ------------------ Fin de l’exercice --------------
int a=5, ∗P ; P=&a ;
Erreur cout«a«”\t”«P«endl; Question 30 ( 2 pts )
boucle infini } int main()
L’adresse de a est : 0x69fefc {
Question 17 ( 3 pt ) L’adresse de P est : 0x69fef8 int a ;
int main() for( a = 1 ; a<10 ; a++) ;
{ 5 0x69fef8
cout« ”\t”«a ;
int a=10,b=20,c=30; 5 5 }
int &x=a, &y=b, x=a+y;
int &x=c, ++c ; 5 0x69fefc
9
cout«a«”;”«b«”;”«c«endl; Question 24 ( 3 pts )
} int main() 1 2 3 4 5 6 7 8 9 10
{ 10
30;20;31 Erreur int B[]={1,3,5,7,9},∗p1,∗p2;
p1=&B[1]; p2=p1+B[0]; 1 2 3 4 5 6 7 8 9
30;20;30
cout« p1 «’\t’ « p2 «”\t”« ∗p2-∗p1 «endl; Question 31 ( 1 pt )
10;20;30 20;10;30 } int main()
Question 18 ( 2 pt ) Dans les réponses proposées, les quantités p1 et p2 sont {
int main() exprimés sous forme de B+i au lieu de 0x… int a = 10;
{ B+1 B+2 2 do
int A[5]={10,20,30,40},i; { a-- ; cout« ”\t”«a ; }
for(i=0;i<5;i++) 3 5 2 while ( a >1);
cout«∗A+i«”\t” ; B+1 B+3 4 }
} 3 7 2 9 8 7 6 5 4 3 2 1 0
Erreur B+1 B+2 3 9 8 7 6 5 4 3 2
10 20 30 40
---------------- Début de l’exercice --------------- 9 8 7 6 5 4 3 2 1
10 11 12 13 14 Exercice Question 32 ( 3 pts )
10 20 30 40 0 int main()
Question 19 ( 2 pt ) int main() {
int main() { int a = 1;
{ int x = 5 , y = 3 , z=1 , a=7 ,∗p,k; do
int a=5, b=10 ; cout « &x « ’\t’ « &y « ’\t’ « &z « ’\t’ « &a « { a++; cout«”\t”«a ;}
char c; c=’+’ ; endl; while(a==2 && a<5);
switch(c) for(p=&a,k=1;k<4;k++) }
{ {
case ’-’ : cout«a-b«’\t’ ; ∗p = 2 ∗ k + 1; 2
case ’+’ : cout«a+b«’\t’ ; p++;
} Boucle infini
case ’∗’ : cout«a∗b«’\t’ ;
case ’/’ : cout«a/b«’\t’ ; cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl; 2 3
} cout«p-&z«’\t’ « y-k «endl;
∗p = 0 ; 1 2 3 4
}
∗(p − 1) = 2; 2 3 4 5
15 15 50 0.5 cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl;
p-=x; Question 33 ( 1 pt )
15 50 0 -5 15 50 0.5 ∗p = a; int main()
∗(p − 1) = k ; {
Question 20 ( 2 pt ) cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl; int a = 0;
int main() } while ( a < 8)
{ { cout« ”\t”«a; a++; }
int A[5],i; Question 25 ( 2 pts ) }
for(i=0;i<5;i++)
{ 0x69fed0 0x69fed0 0x69fec8 0x69fecc 0 1 2 3 4 5 6
A+i=i∗10 ; 0x69fec8 0x69fecc 0x69fed0 0x69fed4
cout«∗(A+i)«”\t”; 1 2 3 4 5 6 7 8
} 0x69fed0 0x69fed4 0x69fecc 0x69fec8
0 1 2 3 4 5 6 7
} 0x69fed4 0x69fed0 0x69fecc 0x69fec8

y y
y +3/1/56+ y

Université Cadi Ayyad, Faculté des Science Semlalia, Département de Physique, Filière SMP–S4
Contrôle de rattrapage- EPR Théorique - Informatique, Durée : 1h30
Session Printemps 2021

0 1 2 3 4 5 6 7 8 9 ←− Codez votre N° Apogée en noircissant les cases correspondantes.


Chaque ligne correspond à un de chiffre du numéro apogée.
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 N° Apogée / Nom et Prénom
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9

Consignes
Vous avez droit à une et une seule copie. Lire attentivement l’énoncé de la question avant de NOIRCIR ( ) la bonne réponse. Utiliser un stylo bleu ou un stylo
noir. Une mauvaise réponse fait perdre des points. L’absence de réponse vaut 0 point. Pour des raisons d’organisation, nous avons omis volontairement dans chaque
question, l’entête suivante:
#include<iostream>
using namespace std;

------------------------------------------------ Début de l’epreuve -------------------------------------------------------------------------


Qu’affichent les programmes suivants après exécution ? Cochez la bonne réponse (Toutes les questions ont une seule bonne réponse).

Question 1 ( 2 pt ) Erreur Erreur


int main() 10 20 30 40
{ 2 3 3.5 4
int x=2, y=5, p=7 ; Question 6 ( 3 pt ) 10 20 30 40 50
p = (x++ , y++) ; float devise (float euro, float dollar=0,float li_st=0) 0 10 20 30 40
cout«p ; {
} float dirham=0; Question 10 ( 2 pt )
dirham+=euro∗10.58; int main()
5 3 2 6 dirham+=dollar∗8.92 ; {
dirham+=li_st∗12.33 ; return dirham ; int A[5]={10,20,30,40},i;
Question 2 ( 2 pts ) for(i=0;i<5;i++)
int main() }
int main() cout«A[i]«”\t” ;
{ }
int x=1, y=0 ; bool p ; {
p = x++ && ++y ; cout«devise(1)«endl;
} 10 20 30
cout«p«”\t”«x«”\t”«y ;
} 10 20 30 40
12.33 0 10 20 30 40 0
1 1 1 Erreur Erreur
0 2 1 8.92 10.58
Question 11 ( 2 pt )
0 2 0 int main()
Question 7 ( 3 pt ) {
1 2 1 int main() int A[5]={10,20,30,40},i;
Question 3 ( 1 pt ) { for(i=0;i<5;i++)
int main() int a=10, b=20 ; cout«∗A+i«”\t” ;
{ int &x=a , &y=b ; }
int k=1 , x=2 , y=5, z; x=a+y++ ;
z = k++ ∗ x + y ; cout«a«”;”«b«endl; 10 20 30 40
cout « ”z=”« z « endl; }
10 20 30 40 0
}
10 ; 20 Erreur Erreur
c=7 c=9 c=14 31 ; 21 10 11 12 13 14
Question 4 ( 1 pt ) 30 ; 21 30 ; 20 Question 12 ( 3 pt )
int main() int main()
{ Question 8 ( 3 pt ) {
int x=2 , y=1 , z=3; int main() int a=10,b=20,c=30;
z = y =++x ; { int &x=a, &y=b, x=a+y;
cout « x«”\t”« y «”\t”«z; int ∗a,∗b,∗maxi; int &x=c, ++c ;
} ∗a=5 , ∗b=10 ; cout«a«”;”«b«”;”«c«endl;
if(∗a>∗b) maxi=b ; }
2 3 3 else maxi=b ;
2 1 3 cout«maxi«endl; 10;20;30 Erreur
} 20;10;30
3 3 3 On donne: &a=0x6ffe1c &b=0x6ffe18 &maxi=0x6ffe10
30;20;31 30;20;30
Question 5 ( 3 pt ) 0x6ffe18 0x6ffe1c
int main() Question 13 ( 2 pt )
{ N’affiche rien 10 int main()
float a=2,b=4,x,h=a/b; {
for( ;a<b; ) Question 9 ( 2 pt ) int a=5, b=10 ;
{ int main() char c; c=’+’ ;
a+=h ; cout«a«”\t”; { switch(c)
} int A[5],i; {
} for(i=0;i<5;i++) case ’-’ : cout«a-b«’\t’ ;
{ case ’+’ : cout«a+b«’\t’ ;
2 2.5 3 3.5 A+i=i∗10 ; case ’∗’ : cout«a∗b«’\t’ ;
boucle infini cout«∗(A+i)«”\t”; case ’/’ : cout«a/b«’\t’ ;
} }
2.5 3 3.5 4 } }

y y
y +3/2/55+ y

15 50 0.5 15 50 0 Question 21 ( 3 pts ) 2 2 3


int main() 3 2 1
15 -5 15 50 0.5 {
int a = 1; 2 4 5
Question 14 ( 1 pt ) do
int main() { a++; cout«”\t”«a ;} Question 28 ( 1 pt )
{ while(a==2 && a<5); void affiche(int a)
int B[]={7,5,3,0,1} ; } {
cout«∗B-1; a=5;
} 1 2 3 4 }
int main()
Valeur affichée est incorrecte 2 {
Boucle infini int a=2 ;
Erreur affiche(a);
6 2 3 cout«a«endl;
2 3 4 5 }
Question 15 ( 1 pt )
int main() ---------------- Début de l’exercice --------------- 2 5 Erreur
{ Exercice
int B[5]={1,3,5,7,9}; Question 29 ( 3 pts )
B++ ; cout«B ; void fonction (int a , int b)
int main() {
} { a--; ++b;
int x = 5 , y = 3 , z=1 , a=7 ,∗p,k; }
Erreur 0x22fef4 1 cout « &x « ’\t’ « &y « ’\t’ « &z « ’\t’ « &a « int main()
endl; {
Question 16 ( 2 pts ) for(p=&a,k=1;k<4;k++)
int main() int a= 3 , b= 7;
{ fonction (a , b);
{ ∗p = 2 ∗ k + 1;
int B[6]={1,9,7,5,3,8}, i ; cout«a«’\t’«b;
p++; }
for(i=5;i>=0;i=i-2) }
cout«B[i]«”\t”; cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl; 2 7
} cout«p-&z«’\t’ « y-k «endl;
∗p = 0 ; 2 8
1 9 7
∗(p − 1) = 2; 3 8
8 5 9 cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl; 0 0
p-=x;
1 7 3 ∗p = a; 3 7
8 3 5 ∗(p − 1) = k ;
cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl; Question 30 ( 2 pts )
Question 17 ( 2 pts ) } int main()
int main() {
{ Question 22 ( 2 pts )
int x=0 , y=2 ;
int B[6]={5,1,4,8,3,2}, i ; if (x>5 && (++y)<1 ) x=4;
for(i=1;i<=5;i++) 0x69fed0 0x69fed4 0x69fecc 0x69fec8
else x=6;
cout«B[i]«”\t”; 0x69fed0 0x69fed0 0x69fec8 0x69fecc cout«”y = ”«y«endl ;
} 0x69fec8 0x69fecc 0x69fed0 0x69fed4 }
1 4 8 3 0x69fed4 0x69fed0 0x69fecc 0x69fec8 y=3 y=1 y=4 y=2
1 4 8 3 2 Question 23 ( 2 pts )
1 4 8 Question 31 ( 3 pts )
7 5 5 3 int main()
5 1 4 8 3 2 5 5 7 3 {
int B[]={1,3,5,7,9},∗p1,∗p2;
5 7 3 5 p1=&B[1]; p2=p1+B[0];
Question 18 ( 2 pts )
int main() 5 7 5 3 cout« p1 «’\t’ « p2 «”\t”« ∗p2-∗p1 «endl;
{ }
Question 24 ( 2 pts ) Dans les réponses proposées, les quantités p1 et p2 sont
int a ;
for( a = 1 ; a<10 ; a++) ; 2 3 exprimés sous forme de B+i au lieu de 0x…
cout« ”\t”«a ; 3 2 B+1 B+2 3
}
-3 3 3 5 2
1 2 3 4 5 6 7 8 9 -3 -2 3 7 2
9 2 2 B+1 B+3 4
1 2 3 4 5 6 7 8 9 10 2 -3 B+1 B+2 2
10 Question 25 ( 2 pts ) Question 32 ( 2 pts )
Question 19 ( 1 pt ) int main()
0 2 5 3 {
int main()
{ 0 2 3 5 int a= 2, b= 5 , ∗p1, ∗p2;
int a = 10; p1=&a ; p2=&b ; p1=p2;
2 0 5 3 cout «∗p1«”\t”«∗p2«endl;
do
{ a-- ; cout« ”\t”«a ; } 3 5 2 0 }
while ( a >1); Question 26 ( 2 pts ) 2 5
}
3 4 3 5 5 5
9 8 7 6 5 4 3 2 1 3 4 5 3 2 2
9 8 7 6 5 4 3 2 4 3 5 3 5 2
9 8 7 6 5 4 3 2 1 0 4 3 3 5 Question 33 ( 1 pt )
Question 20 ( 1 pt ) ------------------ Fin de l’exercice -------------- int main()
int main() {
{ Question 27 ( 3 pt ) int a=5, ∗P ; P=&a ;
int a = 0; int main() cout«a«”\t”«P«endl;
while ( a < 8) { }
{ cout« ”\t”«a; a++; } int a=3, b=2, c=1 ; L’adresse de a est : 0x69fefc
} c+= b ∗= ++a/=2 ; L’adresse de P est : 0x69fef8
cout«a«”\t”«b«”\t”«c«endl; ; 5 5
1 2 3 4 5 6 7 8 }
5 0x69fefc
0 1 2 3 4 5 6 7 4 8 9
5 0x69fef8
0 1 2 3 4 5 6 2 4 4

y y
y +4/1/54+ y

Université Cadi Ayyad, Faculté des Science Semlalia, Département de Physique, Filière SMP–S4
Contrôle de rattrapage- EPR Théorique - Informatique, Durée : 1h30
Session Printemps 2021

0 1 2 3 4 5 6 7 8 9 ←− Codez votre N° Apogée en noircissant les cases correspondantes.


Chaque ligne correspond à un de chiffre du numéro apogée.
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 N° Apogée / Nom et Prénom
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9 ...............................................................
0 1 2 3 4 5 6 7 8 9

Consignes
Vous avez droit à une et une seule copie. Lire attentivement l’énoncé de la question avant de NOIRCIR ( ) la bonne réponse. Utiliser un stylo bleu ou un stylo
noir. Une mauvaise réponse fait perdre des points. L’absence de réponse vaut 0 point. Pour des raisons d’organisation, nous avons omis volontairement dans chaque
question, l’entête suivante:
#include<iostream>
using namespace std;

------------------------------------------------ Début de l’epreuve -------------------------------------------------------------------------


Qu’affichent les programmes suivants après exécution ? Cochez la bonne réponse (Toutes les questions ont une seule bonne réponse).

Question 1 ( 1 pt ) 3 8 2
int main()
{ 3 7 Boucle infini
int x=2 , y=1 , z=3; 0 0 1 2 3 4
z = y =++x ;
cout « x«”\t”« y «”\t”«z; 2 8 2 3 4 5
} Question 6 ( 3 pt ) Question 10 ( 1 pt )
int main() int main()
2 1 3 { {
2 3 3 int a=3, b=2, c=1 ; int a = 0;
c+= b ∗= ++a/=2 ; while ( a < 8)
3 3 3 cout«a«”\t”«b«”\t”«c«endl; ; { cout« ”\t”«a; a++; }
Question 2 ( 2 pts ) } }
int main()
{ 2 4 4 0 1 2 3 4 5 6
int x=1, y=0 ; bool p ; 2 2 3 1 2 3 4 5 6 7 8
p = x++ && ++y ;
cout«p«”\t”«x«”\t”«y ; 3 2 1 0 1 2 3 4 5 6 7
} 2 4 5 Question 11 ( 2 pts )
4 8 9 int main()
1 2 1 {
0 2 1 Question 7 ( 1 pt ) int a ;
void affiche(int a) for( a = 1 ; a<10 ; a++) ;
1 1 1 cout« ”\t”«a ;
{
0 2 0 a=5; }
}
Question 3 ( 1 pt ) int main() 9
int main() { 10
{ int a=2 ;
int k=1 , x=2 , y=5, z; affiche(a); 1 2 3 4 5 6 7 8 9
z = k++ ∗ x + y ; cout«a«endl;
cout « ”z=”« z « endl; 1 2 3 4 5 6 7 8 9 10
}
}
Erreur 2 5 Question 12 ( 3 pts )
c=9 c=14 c=7 int main()
{
Question 4 ( 2 pt ) Question 8 ( 1 pt ) int B[]={1,3,5,7,9},∗p1,∗p2;
int main() int main() p1=&B[1]; p2=p1+B[0];
{ { cout« p1 «’\t’ « p2 «”\t”« ∗p2-∗p1 «endl;
int x=2, y=5, p=7 ; int a = 10; }
p = (x++ , y++) ; do Dans les réponses proposées, les quantités p1 et p2 sont
cout«p ; { a-- ; cout« ”\t”«a ; } exprimés sous forme de B+i au lieu de 0x…
} while ( a >1);
} B+1 B+2 3
2 3 5 6 3 7 2
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1 0 3 5 2
Question 5 ( 3 pts )
void fonction (int a , int b) B+1 B+2 2
9 8 7 6 5 4 3 2
{ B+1 B+3 4
a--; ++b; Question 9 ( 3 pts )
} int main() Question 13 ( 2 pts )
int main() { int main()
{ int a = 1; {
int a= 3 , b= 7; do int a= 2, b= 5 , ∗p1, ∗p2;
fonction (a , b); { a++; cout«”\t”«a ;} p1=&a ; p2=&b ; p1=p2;
cout«a«’\t’«b; while(a==2 && a<5); cout «∗p1«”\t”«∗p2«endl;
} } }
2 7 2 3 5 2

y y
y +4/2/53+ y

2 5 { 1 4 8 3
2 2 float dirham=0;
dirham+=euro∗10.58; 1 4 8 3 2
5 5 dirham+=dollar∗8.92 ; 5 1 4 8 3 2
Question 14 ( 1 pt ) dirham+=li_st∗12.33 ; return dirham ;
} Question 27 ( 1 pt )
int main() int main()
{ int main()
{ {
int a=5, ∗P ; P=&a ; int B[5]={1,3,5,7,9};
cout«a«”\t”«P«endl; cout«devise(1)«endl;
} B++ ; cout«B ;
} }
L’adresse de a est : 0x69fefc
L’adresse de P est : 0x69fef8 10.58 0
Erreur 1 0x22fef4
5 0x69fef8 8.92
5 0x69fefc 12.33 Erreur Question 28 ( 2 pts )
5 5 int main()
Question 21 ( 3 pt ) {
int main() int x=0 , y=2 ;
Question 15 ( 2 pt ) {
int main() if (x>5 && (++y)<1 ) x=4;
int a=10, b=20 ; else x=6;
{ int &x=a , &y=b ;
int A[5]={10,20,30,40},i; cout«”y = ”«y«endl ;
x=a+y++ ; }
for(i=0;i<5;i++) cout«a«”;”«b«endl;
cout«A[i]«”\t” ; } y=4 y=1 y=3 y=2
}
10 ; 20 30 ; 20
10 20 30 ---------------- Début de l’exercice ---------------
30 ; 21
Erreur Exercice
Erreur 31 ; 21
10 20 30 40 int main()
10 20 30 40 0 Question 22 ( 3 pt ) {
int main() int x = 5 , y = 3 , z=1 , a=7 ,∗p,k;
Question 16 ( 2 pt ) {
int main() cout « &x « ’\t’ « &y « ’\t’ « &z « ’\t’ « &a «
int ∗a,∗b,∗maxi; endl;
{ ∗a=5 , ∗b=10 ;
int A[5]={10,20,30,40},i; for(p=&a,k=1;k<4;k++)
if(∗a>∗b) maxi=b ; {
for(i=0;i<5;i++) else maxi=b ;
cout«∗A+i«”\t” ; ∗p = 2 ∗ k + 1;
cout«maxi«endl; p++;
} } }
10 20 30 40 0 On donne: &a=0x6ffe1c &b=0x6ffe18 &maxi=0x6ffe10 cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl;
Erreur cout«p-&z«’\t’ « y-k «endl;
10 0x6ffe1c ∗p = 0 ;
10 11 12 13 14 N’affiche rien 0x6ffe18 ∗(p − 1) = 2;
10 20 30 40 cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl;
Question 23 ( 3 pt ) p-=x;
Question 17 ( 2 pt ) int main() ∗p = a;
int main() { ∗(p − 1) = k ;
{ float a=2,b=4,x,h=a/b; cout « x « ’\t’ « y « ’\t’ « z « ’\t’ « a « endl;
int A[5],i; for( ;a<b; ) }
for(i=0;i<5;i++) {
{ a+=h ; cout«a«”\t”; Question 29 ( 2 pts )
A+i=i∗10 ; }
cout«∗(A+i)«”\t”; } 0x69fec8 0x69fecc 0x69fed0 0x69fed4
} 0x69fed4 0x69fed0 0x69fecc 0x69fec8
} 2 2.5 3 3.5
0x69fed0 0x69fed4 0x69fecc 0x69fec8
Erreur boucle infini
2.5 3 3.5 4 0x69fed0 0x69fed0 0x69fec8 0x69fecc
10 20 30 40 50
10 20 30 40 2 3 3.5 4 Question 30 ( 2 pts )
0 10 20 30 40 Erreur 5 7 5 3
Question 18 ( 2 pt ) Question 24 ( 2 pts ) 5 5 7 3
int main() int main()
{ { 7 5 5 3
int a=5, b=10 ; int B[6]={1,9,7,5,3,8}, i ; 5 7 3 5
char c; c=’+’ ; for(i=5;i>=0;i=i-2)
switch(c) cout«B[i]«”\t”; Question 31 ( 2 pts )
{ }
case ’-’ : cout«a-b«’\t’ ; 2 -3
8 3 5
case ’+’ : cout«a+b«’\t’ ; 3 2
case ’∗’ : cout«a∗b«’\t’ ; 1 7 3
case ’/’ : cout«a/b«’\t’ ; -3 3
1 9 7
} 2 2
} 8 5 9
2 3
Question 25 ( 1 pt )
15 15 50 0.5 int main() -3 -2
-5 15 50 0.5 15 50 0 {
int B[]={7,5,3,0,1} ; Question 32 ( 2 pts )
Question 19 ( 3 pt ) cout«∗B-1; 2 0 5 3
int main() }
{ 3 5 2 0
int a=10,b=20,c=30; Valeur affichée est incorrecte
0 2 5 3
int &x=a, &y=b, x=a+y; Erreur
int &x=c, ++c ; 0 2 3 5
cout«a«”;”«b«”;”«c«endl; 6
} Question 26 ( 2 pts ) Question 33 ( 2 pts )
int main() 4 3 3 5
20;10;30 10;20;30 {
30;20;30 int B[6]={5,1,4,8,3,2}, i ; 3 4 5 3
for(i=1;i<=5;i++) 4 3 5 3
30;20;31 Erreur cout«B[i]«”\t”;
} 3 4 3 5
Question 20 ( 3 pt )
float devise (float euro, float dollar=0,float li_st=0) 1 4 8 ------------------ Fin de l’exercice --------------

y y

Vous aimerez peut-être aussi