Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit 81fee76

Browse files
authored
Merge pull request #173 from tahabinaziz/Min-&-Max-No
Max & Min No.
2 parents 43a01f1 + 87e7891 commit 81fee76

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

CONTRIBUTORS.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@
4040
- [Rabin Khatiwada](https://github.com/rabinkhatiwada)
4141
- [Adrian Hernandez-Lopez](https://github.com/AdrianHL)
4242
- [Juan Benitez](https://github.com/juanbenitez)
43-
- [Chaiyapat Tantiworachot](https://github.com/pixelart7)
43+
- [Chaiyapat Tantiworachot](https://github.com/pixelart7)
44+
- [Taha Bin Aziz](https://github.com/tahabinaziz)

source/snippets/csharp/index.md

+42
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,45 @@ private void Shuffle(string[] e)
2525
}
2626
}
2727
```
28+
# C#
29+
30+
## Minimum And Maximum Number
31+
32+
```csharp
33+
int[] arr1= new int[100];
34+
int i, mx, mn, n;
35+
36+
37+
Console.Write("\n\nFind maximum and minimum element in an array :\n");
38+
Console.Write("--------------------------------------------------\n");
39+
40+
Console.Write("Input the number of elements to be stored in the array :");
41+
n= Convert.ToInt32(Console.ReadLine());
42+
43+
Console.Write("Input {0} elements in the array :\n",n);
44+
for(i=0;i<n;i++)
45+
{
46+
Console.Write("element - {0} : ",i);
47+
arr1[i] = Convert.ToInt32(Console.ReadLine());
48+
}
49+
50+
51+
mx = arr1[0];
52+
mn = arr1[0];
53+
54+
for(i=1; i<n; i++)
55+
{
56+
if(arr1[i]>mx)
57+
{
58+
mx = arr1[i];
59+
}
60+
61+
62+
if(arr1[i]<mn)
63+
{
64+
mn = arr1[i];
65+
}
66+
}
67+
Console.Write("Maximum element is : {0}\n", mx);
68+
Console.Write("Minimum element is : {0}\n\n", mn);
69+
```

0 commit comments

Comments
 (0)