Skip to content

Instantly share code, notes, and snippets.

@gokhanyavas
Created May 16, 2013 07:31
Show Gist options
  • Save gokhanyavas/5590026 to your computer and use it in GitHub Desktop.
Save gokhanyavas/5590026 to your computer and use it in GitHub Desktop.
Ana köşegen üzerindeki elemanları “1” , diğer bütün elemanları “0” olan matrise “birim matris” denir. Dışarıdan girilen N sayısına göre NxN tipinde birim matris oluşturan c programı.
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,n;
int mat[10][10];
printf("Kare Matrisin Boyutunu Giriniz..:");
scanf("%d",&n);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if (i==j) mat[i][j]=1;
else mat[i][j]=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("%3d",mat[i][j]);
printf("\n");
getch();
}
}
@Songulgenc
Copy link

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,n;
int mat[10][10];
printf("Kare Matrisin Boyutunu Giriniz..:");
scanf("%d",&n);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if (i==j) mat[i][j]=1;
else mat[i][j]=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("%3d",mat[i][j]);
printf("\n");
getch();
}
}

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