Skip to content
Snippets Groups Projects
Commit ded435a1 authored by ATMITIM YAHYA's avatar ATMITIM YAHYA
Browse files

tp1 terminé

parent c2c5e831
No related merge requests found
#include <stdlib.h>
#include <stdio.h>
#define N 10
//fonction affiche somme des elements de deux tableau dans un troisieme tab
void somme_tab(int tab1[], int tab2[], int res_tab[]){
for (int i = 0; i < N ; i++){
res_tab[i]= tab1[i] + tab2[i];
}
for (int j = 0; j < N ; j++){
printf("res_tab[%d]=%d \n",j, res_tab[j]);
}
}
int main(){
/*
int nb = rand();
int p;
printf("Entrez votre nombre : ");
......@@ -22,13 +31,19 @@ int main(){
}
printf("%d est le nombre mystere \n",p);
printf("%d est le nombre mystere \n",p); */
// exercice 6
int somme = 0;
int tab[N]= {1,2,3,4,5,6,7,8,9,10};
int tab1[N]= {1,2,3,4,5,6,7,8,9,10};
/*int somme = 0;
for(int i = 0; i < N; i++){
somme += tab[i];
somme += tab[i];
}
printf("la somme des elements du tableau est : %d", somme);
printf("la somme des elements du tableau est : %d \n", somme); */
int tab2[N]={2,2,3,4,5,6,7,7,8,90};
int res_tab[N];
somme_tab(tab1,tab2,res_tab);
return 0;
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment