TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sandeep Banerjee
NA
249
264k
Identity matrix in C#
Mar 7 2015 4:10 PM
sir how to check identity matrix
using System;
public class IdtMat
{
public static void Main()
{
int i, j, row, col;
int[,] matA = new int[10,10];
Console.Write("\nEnter the no. of row: ");
i=Convert.ToInt16(Console.ReadLine());
Console.Write("Enter the no. of col: ");
j=Convert.ToInt16(Console.ReadLine());
Console.WriteLine("\nEnter the Element in Matrix: ");
for(row=0; row<i; row++)
{
for(col = 0; col<j; col++)
matA[row,col]= Convert.ToInt16(Console.ReadLine());
Console.WriteLine();
}
Console.WriteLine("\nMatrix A: ");
for(row=0; row<i; row++)
{
for(col = 0; col<j; col++)
Console.Write("{0:D2} ", matA[row,col]);
Console.WriteLine();
}
for(row = 0; row < i; row++)
{
for(col = 0; col<j; col++)
{
if ((row == col && matA[row, col] == 1) && (row != col && matA[row, col] == 0))
{
goto lable;
}
else
{
Console.WriteLine("\n Not an Identity Matrix");
row=col=i;
}
}
}
lable: Console.WriteLine("Identity matrix");
Console.ReadLine();
}
}
this program is not working every time it prints identity matrix for the input
3 0 0
0 3 0
0 0 3
Reply
Answers (
2
)
where can i get C# learning guidance as begineer?
c# using mysql plus return data