class Program
{
static void Main(string[] args)
{
int[]
a = new int[5];
bool flag = true;
Console.WriteLine("Enter
5 Numbers : ");
for (int i = 0; i
< a.Length; i++)
a[i] = int.Parse(Console.ReadLine());
for (int i = 0; i
< a.Length - 1; i++)
{
if (a[i] + 1 != a[i + 1])
{
flag = false;
break;
}
}
if (flag)
{
Console.WriteLine("\nGiven Array elemenets are Consecutive");
}
else
{
Console.WriteLine("\nGiven Array elemenets are Not Consecutive");
}
Console.ReadLine();
}
}
Output 1:
No comments:
Post a Comment