Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* CABEÇALHO
- Arquivo: LISTA 05 - Exercicio 6.c
- Objetivo: Exibir a matriz de numeros e a soma dos valores contidos na 5ª linha.
- Autor(a): Ramon Borges
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define LIN 10
- #define COL 10
- int main()
- {
- int m[LIN][COL], i, j, soma = 0;
- srand(time(NULL));
- for(i = 0; i < LIN; i++)
- for(j = 0; j < COL; j++)
- m[i][j] = rand()%10;
- for(i = 0; i < LIN; i++)
- for(j = 0; j < COL; j++)
- printf("m[%d,%d] = %d\n", i+1, j+1, m[i][j]);
- for(i = 0; i < LIN; i++)
- {
- for(j = 0; j < COL; j++)
- {
- printf("%d ", m[i][j]);
- if(i == 4) //Faz a soma dos numeros presentes na 5ªlinha.
- soma += m[i][j];
- }
- printf("\n");
- }
- printf("\nA soma dos numeros presentes na quinta linha = %d\n\n", soma);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment