## Write a program to enter 10 integers in a single dimensional array and then print out the array in descending order.

**So let’s Write Code:**

**Let’s build logic First:**

**Algorithm for code:**

**St**Start**ep 1:**Declare an array and variable.**Step 2:**Take inputs from user.**Step 3:**Passing array to function**Step 4:**Defining sort Function**Step 5:****void sort ( int x [ ])**Check Condition**Step 6:****if (x [i] > x [i+1]**) to find minimum value for sort array in ascending order.if value in**Step 7:****x[i] > [i + 1]**then exchange values, repeat this process until**i <=9.**Print elements**Step 8:**Finish Program**Step 9:**

**Code:**

**Write a program to enter 10 integers in a single-dimensional array and then print out the array in descending order. **

```
#include<iostream>
using namespace std;
main()
{
int arr[10], i;
void sort(int []);
cout<<"Enter ten integer values in array\n";
for(i = 0; i<=9; i++)
{
cout<<"Enter value in element "<<i<<" ? ";
cin>>arr[i];
}
sort(arr);
cout<<"\nValues of array after sorting\n";
for(i = 0; i<=9; i++)
cout<<arr[i]<<" ";
getch();
}
// definition of sort() function
void sort(int x[])
{
int i, u, temp;
u = 9;
while(u>=1)
{
i = 0;
while(i<u)
{
if(x[i] < x[i+1])
{
temp = x[i];
x[i] = x[i+1];
x[i+1] = temp;
}
i++;
}
u--;
}
}
```

**Hope You will learn Something. Happy Coding.**

###### Visit my YouTube Channel as Well๐ https://www.youtube.com/watch?v=JuIHQ9cLSEw&list=PLbIhkHxfUIItTdcyCb34uRIrPJbXBndIl&index=4

**Click on the below Links for more Programming Exercises: **

**Conditional Structure Exercises: **๐https://myustaadg.com/category/programming-exercises/conditional-structures-exercises/

**Array Exercises: ๐**https://myustaadg.com/category/programming-exercises/arrays-exercises/