answersLogoWhite

0

Here is the C program to check whether the inputted matrix is scalar matrix or not. ( its not my creation, its get from other website,am not check)

#include<stdio.h>

#include<conio.h>

int main()

{

int a[10][10],i,j,m,n,f=0;

printf("Enter the order of the matrix\n");

scanf("%d%d",&m,&n);

printf("Enter the matrix\n");

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

scanf("%d",&a[i][j]);

}

}

if(m!=n)

{

printf("The matrix is not identity");

}

else

{

for(i=0;i<m;i++)

{

for(j=0;j<n;j++)

{

if((i==j&&a[i][j]!=a[0][0])(i!=j&&a[i][j]!=0))

{

printf("The matrix is not scalar\n");

f=1;

break;

}

}

if(f==1)

{

break;

}

}

if(f==0)

{

printf("The matrix is scalar\n");

}

}

getch();

return 0;

}

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra

Add your answer:

Earn +20 pts
Q: C program to read and print a scalar matrix?
Write your answer...
Submit
Still have questions?
magnify glass
imp