# C# Program to find saddle point in a matrix

In this program, You will learn how to find saddle point in a matrix in C#.

``````2 3 4

5 6 7

8 9 10

## Example: How to find saddle point in a matrix in C#.

``````using System;
public class Program
{
public static void Main(string[] args)
{
int i, j, num, sm, p, larg, f = 1;
int[,] a = new int[10, 10];

Console.Write("Enter size of an matrix:");

Console.Write("Enter 2D array elements:");
for (i = 0; i < num; i++)
{
for (j = 0; j < num; j++)
{
}
}

Console.Write("\n2D Array List is :\n\n");
for (i = 0; i < num; i++)
{
for (j = 0; j < num; j++)
{
Console.Write(a[i, j] + " ");
}
Console.WriteLine();
}

/* Logic start from here */
for (i = 0; i < num; i++)
{
p = 0;
sm = a[i, 0];
for (j = 0; j < num; j++)
{
if (sm >= a[i, j])
{
sm = a[i, j];
p = j;
}
}
larg = 0;
for (j = 0; j < num; j++)
{
if (larg < a[j, p])
{
larg = a[j, p];
}
}
if (sm == larg)
{
Console.WriteLine("\nValue of Saddle Point :" + sm);
f = 0;
}
}

if (f > 0)
{
}
}
}``````

#### Output:

``````Enter size of an matrix:3
Enter 2D array elements:1
2
3
4
5
6
7
8
9

2D Array List is :

1 2 3
4 5 6
7 8 9