C# Sharp Exercises: Check whether it is possible to create a strictly increasing sequence from a given sequence of integers as an array
C# Sharp Basic: Exercise-59 with Solution
Write a C# program to check whether it is possible to create a strictly increasing sequence from a given sequence of integers as an array.
Sample Solution:
C# Sharp Code:
using System;
public class Example
{
public static bool test_Increasing_Sequence(int[] int_seq)
{
int x = 0;
for (int i = 0; i < int_seq.Length - 1; i++)
{
if (int_seq[i] >= int_seq[i + 1])
x++;
if (i + 2 < int_seq.Length && int_seq[i] >= int_seq[i + 2])
x++;
}
return x <= 2;
}
public static void Main()
{
Console.WriteLine(test_Increasing_Sequence(new int[] {1,3, 5,6,9}));
Console.WriteLine(test_Increasing_Sequence(new int[] {0,10}));
Console.WriteLine(test_Increasing_Sequence(new int[] {1, 3, 1, 3}));
}
}
Sample Output:
True True False
Flowchart:
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# program which will accept a list of integers and checks how many integers are needed to complete the range.
Next: Write a C# program to calculate the sum of all the intgers of a rectangular matrix except those integers which are located below an intger of value 0.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework