Skip to content

Instantly share code, notes, and snippets.

@austa
Created March 17, 2013 21:38
Show Gist options
  • Select an option

  • Save austa/5183768 to your computer and use it in GitHub Desktop.

Select an option

Save austa/5183768 to your computer and use it in GitHub Desktop.
/*
* File: main.c
* Author: alaattin
*
* Created on 17 Mart 2013 Pazar, 23:08
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SATIR 3
#define SUTUN 3
/*
*
*/
void matris_olustur(int [][3],int, int);
int matris_topla(int [][3], int, int);
void matris_yazdir(int [][3], int, int);
int main(int argc, char** argv) {
int matris[][3] = {};
int toplam = 0;
matris_olustur(matris, SATIR, SUTUN);
matris_yazdir(matris, SATIR, SUTUN);
toplam = matris_topla(matris, SATIR, SUTUN);
printf("Sonucumuz:%d \n", toplam);
return (EXIT_SUCCESS);
}
void matris_olustur(int dizi[][3], int satirsayisi, int sutunsayisi){
int i = 0, j = 0;
srand(time(NULL));
for(i = 0; i < satirsayisi; i++){
for(j = 0; j < sutunsayisi; j++){
dizi[i][j] = rand() % 10;
}
}
}
void matris_yazdir(int matris [][3], int satirsayisi, int sutunsayisi){
int i = 0, j = 0;
for(i = 0; i < satirsayisi; i++){
for(j = 0; j < sutunsayisi; j++){
printf("Dizimizin elemanları: %d \n", matris[i][j]);
}
}
}
int matris_topla(int matris[][3],int satirsayisi, int sutunsayisi){
int toplam = 0, i = 0, j = 0;
for(i = 0;i < satirsayisi; i++){
for(j = 0; j < sutunsayisi; j++){
toplam += matris[i][j];
}
}
return toplam;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment