## Program to find maximum difference between two elements such that larger element appears after the smaller number

Problem statement
Maximum difference between two elements such that larger element appears after the smaller number

Explanation:
Given an array arr[] of integers, find out the difference between any two elements such that larger element appears after the smaller number in arr[].

Examples:

• If array is [2, 3, 10, 6, 4, 8, 1] then returned value should be 8 (Diff between 10 and 2).
• If array is [ 7, 9, 5, 6, 3, 2 ] then returned value should be 2 (Diff between 7 and 9)

Conclusion:
You have to take first number of array and check it with remaining array elements.
Then find the largest number in remaining array (excluding number at array index 0).
Then find the difference between largest number from remaining array and first number from array.
This will be the largest difference between two elements.

### C program to find maximum difference between two elements such that larger element appears after the smaller number

Output:

Help others by sharing the content!

## C program to print a pattern

Pattern Problem – 5

You need to take an integer input and then draw the pattern according to it. Say for example if you enter 5 then, the pattern should be like this-

Input Format
You will take an integer input n from stdin.

Constraints
1 <= n <= 1000 Output Format
Your output should be the pattern according to the input which you had entered.

Sample TestCase 1
Input
5
Output:

### Write a C program to print the following pattern 5 5 5 5 5 4 4 4 4 4 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 12345 5 5 5 5 54 4 4 4 43 3 3 3 32 2 2 2 21 1 1 1 1

Output:

Help others by sharing the content!

## C program to print below program – Pattern problem 4

You need to take an integer input and then draw the pattern according to it.
Say for example if you enter 6 then, the pattern should be like this-

Input Format
You will take an integer input n from stdin.

Constraints
1 <= n <= 1000

Output Format
Your output should be the pattern according to the input which you had entered.

Sample TestCase 1
Input
5
Output:

### Write a C program to print following pattern A B C D E A B C D E A B C D E A B C D E A B C D E 12345 A B C D EA B C D EA B C D EA B C D EA B C D E

Output

Help others by sharing the content!

## C program to draw a pattern

You need to take an integer input and then draw the pattern according to it.
Say for example if you enter 5 then, the pattern should be like this-
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

Input Format
You will take an integer input n from stdin.

Constraints
1 < = n < = 1000 Output Format
Your output should be the pattern according to the input which you had entered.

Sample TestCase 1
Input
5
Output

### Write a C program to print following pattern 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 12345 1 2 3 4 51 2 3 4 51 2 3 4 51 2 3 4 51 2 3 4 5

Program:

Output:

Help others by sharing the content!

## C program to print below program – Pattern problem 2

You need to take an integer input and then draw the pattern according to it.
Say for example if you enter 6 then, the pattern should be like this-

Input Format
You will take an integer input n from stdin.

Constraints
1 <= n <= 1000

Output Format
Your output should be the pattern according to the input which you had entered.

Sample TestCase 1
Input
6
Output:

### Program to print * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 123456 * * * * ** * * * ** * * * ** * * * ** * * * ** * * * *

Output

Help others by sharing the content!