Skip to content

Instantly share code, notes, and snippets.

@gokhanyavas
Created May 16, 2013 06:34
Show Gist options
  • Save gokhanyavas/5589785 to your computer and use it in GitHub Desktop.
Save gokhanyavas/5589785 to your computer and use it in GitHub Desktop.
NxN boyutlu bir matrisin esas köşegenin elemanlarının toplamını bulan C programı
#include <stdio.h>
#include<conio.h>
int main ()
{
int n, i, j, toplam;
toplam =0;
int mat[10][10];
printf("Matrisin boyutunu giriniz : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
printf("%d. satir ,%d.sutun elemani : ",i,j);
scanf("%d",&mat[i][j]);
}
for(i=1;i<=n;i++)
toplam=toplam+mat[i][i];
printf("Toplam : %d",toplam);
getch();
}
@tugrulaydos
Copy link

tugrulaydos commented Apr 10, 2020

Bu da Ters Köşegen Toplamlarını Veriyor Hocam
#include<stdio.h>

int main()

{

  int n;
int toplam=0;
printf("N Degerini Giriniz:");
scanf("%d",&n);
int N = n;
int sayac=0;
int dizi[n][n]; 

for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
	{
		printf("%d.Degeri Giriniz:",++sayac);
		scanf("%d",&dizi[i][j]);
	}
	toplam += dizi[i][--N];  
	
}
printf("\n\n");
for(int i=0;i<n;i++)
{
	for(int j=0;j<n;j++)
	{
		printf("%d\t",dizi[i][j]);
	}
	printf("\n\n\n");
}
printf("\n\n");

printf("Ters Kosegen Toplamlari:%d",toplam);
return 0;

}

@gokhanyavas
Copy link
Author

çok teşekkürler.

@arslanatakan
Copy link

Teşekkürler hocalarım.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment