Computer Science, asked by pallabimishra, 6 months ago

Write a program to input 20 characters into an array and print it.Then arrange them in descending order and print it.

Please do it soon and don't give answer if u don't know.​

Answers

Answered by Mister360
1

Explanation:

Let's use C

code:-

/*

* C program to accept a set of numbers and arrange them

* in a descending order

*/

#include <stdio.h>

void main ()

{

int number[30];

int i, j, a, n;

printf("Enter the value of N\n");

scanf("%d", &n);

printf("Enter the numbers \n");

for (i = 0; i < n; ++i)

scanf("%d", &number[i]);

/* sorting begins ... */

for (i = 0; i < n; ++i)

{

for (j = i + 1; j < n; ++j)

{

if (number[i] < number[j])

{

a = number[i];

number[i] = number[j];

number[j] = a;

}

}

}

printf("The numbers arranged in descending order are given below\n");

for (i = 0; i < n; ++i)

{

printf("%d\n", number[i]);

}

}

Answered by jai696
8

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

from string import ascii_lowercase

def sort_arr(arr):

arr_len = len(arr)

for i in range(0, arr_len):

for j in range(i + 1, arr_len):

if arr[i] < arr[j]:

arr[i], arr[j] = arr[j], arr[i]

return arr

# initialise array with 20 characters

chars = list(ascii_lowercase)[0:20]

print(chars)

print(sort_arr(chars))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions