Page 617 - IT2
P. 617
PARTIE 2: PRATIQUE (80 PTS)
DOSSIER 1 : LANGAGE DE PROGRAMMATION STRUCTURE (26 PTS)
Exercice 1 (12 pts)
Quel est le résultat d’affichage du programme suivant :
#include <stdio.h>
int f1(int y, int *x)
{
printf("debut f1 : *x=%d, y=%d\n", *x,y); //2pts
int z=-1;
y = z+2;
*x = y+6;
printf("fin f1 : *x=%d, y=%d\n", *x,y); //4pts
return (*x*5);
}
void main()
{
int x=1, y=3;
printf("debut main : x=%d, y=%d\n", x,y); //2pts
y=f1(x, &y);
printf("fin main : x=%d, y=%d\n", x,y); //4pts
getchar();
}
Exercice 2 : (14 pts)
Soit le programme suivant :
#include <stdio>
void f1(char s[], char res[])
{
int j = 0;
for ( int i = 0; s[i] != '\0'; )
{ int cmpt = '1';
char c = s[i];
for ( i=i+1; ((c == s[i]) && (cmpt != '9')); i=i+1, cmpt=cmpt+1 );
res[j] = cmpt ; j=j+1;
res[j] = c; j=j+1;
}
res[j] = '\0';
}
void main()
{
char res[100];
char s2[] = "aaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbcddde";
f1(s2, res);
printf("%s\n", res);
Filière Epreuve Session 5/8
TDI (CDS de 1 à 2) Synthèse V2 Juillet 2014
www.itlearning-settat.com
Email: admission@itlearning-settat.com
Tél.:0661077812

