ramontricolor12

LISTA 05 - Exercício 06

Jul 8th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 05 - Exercicio 6.c
  3.    Objetivo: Exibir a matriz de numeros e a soma dos valores contidos na 5ª linha.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <time.h>
  10. #define LIN 10
  11. #define COL 10
  12. int main()
  13. {
  14.     int m[LIN][COL], i, j, soma = 0;
  15.  
  16.     srand(time(NULL));
  17.     for(i = 0; i < LIN; i++)
  18.         for(j = 0; j < COL; j++)
  19.             m[i][j] = rand()%10;
  20.  
  21.     for(i = 0; i < LIN; i++)
  22.         for(j = 0; j < COL; j++)
  23.             printf("m[%d,%d] = %d\n", i+1, j+1, m[i][j]);
  24.  
  25.     for(i = 0; i < LIN; i++)
  26.     {
  27.         for(j = 0; j < COL; j++)
  28.         {
  29.             printf("%d  ", m[i][j]);
  30.             if(i == 4)              //Faz a soma dos numeros presentes na 5ªlinha.
  31.                 soma += m[i][j];
  32.         }
  33.         printf("\n");
  34.     }
  35.     printf("\nA soma dos numeros presentes na quinta linha = %d\n\n", soma);
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment