Enter Element in array and stored in ascending
order
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication20
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[10];
int[] b = new int[10];
int n,i,j,temp;
Console.WriteLine("enter limit:
");
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter the
elements of array:");
for (i = 0; i < n; i++)
{
a[i] = Convert.ToInt32(Console.ReadLine());
}
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
if (a[i] > a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
Console.WriteLine("sorted
array:");
for (i = 0; i < n; i++)
{
Console.WriteLine(a[i]);
}
Console.ReadLine();
}
https://www.youtube.com/channel/UCKLRUr6U5OFeu7FLOpQ-FSw/videos
0 comments
Post a Comment