Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 10) Faça um programa para ler 2 vetores A e B com 5 elementos reais e construir um terceiro vetor S obtido com os valores comuns a A e B.
- Ao final, imprimir os 3 vetores.*/
- #include<stdio.h>
- #include<conio.h>
- void preencher (int vetor[5])
- {
- int i;
- for (i=0; i<5; i++)
- {
- printf ("[%d] = ", i);
- scanf ("%d", &vetor[i]);
- }
- }
- void Soma (int X[5], int Y[5], int S[5])
- {
- int i;
- for (i=0; i<5; i++)
- {
- S[i]=X[i]+Y[i];
- }
- }
- void Imprimir (int V[5])
- {
- int i;
- for (i=0; i<5;i++)
- {
- printf ("\n [%d] = %d", i, V[i]);
- }
- }
- main ()
- {
- int A[5], B[5], S[5], i;
- preencher(A);
- printf ("\n \n");
- preencher(B);
- Soma(A,B, S);
- Imprimir (A);
- printf ("\n \n");
- Imprimir (B);
- printf ("\n \n");
- Imprimir (S);
- getch ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement