EXERCICE 4
void fonction(int a[]) { a[1]=10 ;}
void main(void) {
int T[]{1,2,3} ;
fonction(T) ;
cout<< T[1] ;}
Quelle est la valeur affichée ?
B) 1
C) 2
D) c’est une erreur
EXERCICE 5
Qu’affichent les instructions suivantes :
int i=10 ;
while(i>0) { i=i-4 ;
cout << i ;}
A) 10 8 4 2
B) 10 6 2
D) 6 2
EXERCICE 6
void g(int *p) {*p=12 ;}
void main (){
int *p ;
g(p) ;
cout<< *p ; }
Qu’est ce qui s’affiche ?
A) Erreur
B) NULL
D) 0×7ffd8000 (l’adresse de p)
EXERCICE 7
Soit le programme suivant
int t[3] = { 7, 8, 9} ;
Que vaut t[2]+t[3] ?
A) 17
B) 9
C) NULL
EXERCICE 8
Considérons l’en-tête de fonction suivante :
void Fiche(float *X,float *Y, char Z, Char R) ;
considérons les déclarations suivantes :
float A,C ;
int J ;
char B,H ;
Lequel de ses appels de fonctions est juste ?
A) Fiche(A,C ; J ; B,H) ;
B) Fiche(&A, &B , C , J ,H) ;
Fiche
D) Fiche(*A, *C , J , B,H)
EXERCICE 9
Soit le programme ci-dessous :
float z=2 ,
float produit2( float a, float b) {
int p ; float z=5 ;
p=a*b ;
return (z*p) ;
}
void main ()
{int m ; float z ;
z=3 ;
m=produit2(2,2) ;
cout<<m ;
}
ce programme affiche :
A) 8
B) 10
C) 12
EXERCICE 10
#include <stdio.h>
float x ;
void Affectation() {
float x=5 ;
}
void main() {
x=3 ;
affectation() ;
cout << x ;
}
ce programme affiche :
A) 3
B) 5
C) Rien
EXERCICE 11
void fonction (int x) {
x=x+10 ;
cout <<x ; }
int fonction2 (int y) {
return y+20 ; }
A) 11 11 31
B) 11 11 21
============================
Soit la classe :
class complexe
{
private :
int img,reel ;
public :
Complexe (int a, int b)
…
};
============================
EXERCICE 18
Laquelle des définitions de constructeurs avec paramètres est correcte :
A) complexe ::complexe(int a, int b) { img = a ; reel = b ;}
B) complexe(int a , int b) { img = a ; reel = b ;}
C) void complexe :: complexe(int a, int b) { img = a ; reel = b ;}
D) void complexe(int a , int b) img(a) , reel(b) ;
EXERCICE 19 Accesseurs
Quelle instructions est correct pour accéder à l’attribut img ;
A) double Get_img() return img ;
B) int Get_img {return img} ;
C) void Get_img() return img ;
int Complexe::Get_img() {return img}
EXERCICE 20 mutateurs
Quelle instructions est correct pour modifier l’attribut img ;
A) void Set_img() { reel = a ; img = b ;}
B) int Set_img(int a, int b) { return img } ;
C) void Complexe :: Set_img(int a, int b) { return img } ;
void Complexe :: Set_img(int a) { img = a } ;