arrange numbrs in ascending order in c

Solutions on MaxInterview for arrange numbrs in ascending order in c by the best coders in the world

showing results for - "arrange numbrs in ascending order in c"
Mila
24 Jun 2018
1#include <stdio.h>
2#include <conio.h>
3void main ()
4{
5    int a[100];
6    int temp,n,i,j;
7    printf("How many numbers do you want to enter? : ");
8    scanf("%d",&n);
9    for (i=0;i<n;i++)
10    {
11        printf("Enter %d number: ",i+1);
12        scanf("%d",&a[i]);
13    }
14
15    printf("\n\n.....arranging in ascending order.....\n\n");
16
17   for (i = 0; i < n; ++i)
18    {
19
20        for (j = i + 1; j < n; ++j)
21        {
22            if (a[i] > a[j])
23
24            {
25                temp =  a[i];
26                a[i] = a[j];
27                a[j] = temp;
28            }
29        }
30    }
31
32    for (i=0;i<n;i++)
33    {
34        printf("%d ",a[i]);
35    }
36}
37
Mika
07 Aug 2016
1/* C program to arrange numbers in descending order DescOrder.C */
2
3#include <stdio.h>
4 
5void main ()
6{
7 //variable declaration
8 int number[30];
9 int i, j, a, n;
10
11 //asking user to enter size of array 
12 printf("Enter the value of N\n");
13 scanf("%d", &n); //reading array size
14 
15 //asking user to enter array elements
16 printf("Enter the numbers \n"); 
17 for (i = 0; i < n; ++i)
18  scanf("%d", &number[i]); //reading array elements
19
20 /* Logic for sorting and checking */
21
22 for (i = 0; i < n; ++i)
23 {
24   for (j = i + 1; j < n; ++j)
25   {
26    if (number[i] < number[j])
27    {
28     a = number[i];
29     number[i] = number[j];
30     number[j] = a;
31   }
32  }
33 }
34 
35 printf("The numbers arranged in descending order are given below\n");
36 for (i = 0; i < n; ++i)
37 {
38   printf("%d\n", number[i]); //printing numbers in descending order
39 }
40}
queries leading to this page
c program to read an array of 10 integers and sort using in descending using functionhow to sort by number in c programc program to arrange numbers in descending order using arraysort integer in descending order c programsorting an array in descending order c program for descending orderc program to sort an array in descending orderc program to sort numbers in ascending orderhow to make a program in c to to number numbers in ascending and descending orderc program to sort array in ascending and descending orderc program to ask user number and sort in descending ordersort array in descending order c programc program to display numbers in ascending and descending orderarray descending order in cc program to sort the given numbers in an descending orderhow to print array in descending orderarranging array elment to accending or and decindingall numbers must be in ascending order cdescending sort array autometasort numbers in ascending order in cc how to sort 5 numbersdescending sort in cprint numbers in descending order sort integer ascending order in cc program to print numbers in ascending orderdescending order cascending order in csort int in cprogram to sort an array in ascending order in cprint ascending order in cc program to sort array in descending orderc program to print in ascending ordersortning array number in descending order c programingsorting algorithm in descending order in cwrite a program to sort the array in descending order of the frequency of the elements ascending order c program 10code for sorting array in ascending order in cascending order in array in csort int cc program to sort the given numbers in an descending order in by programiza program to get 5 number output from desending in carrange the numbers in ascending order in csorting numbers cc language to input 20 numbers in an array and arrange the numbers in ascending ordersort elements in an array in descending orderc program to put numbers in ascending orderarray in descending order cc program to arrange numbers in ascending order using arraydescending sort arrayarray in descending orderprogram to sort an array in ascending and descending orderalgorithm to sort numbers in descending order in cc program to sort integers in ascending orderarrange array in descending orderascending program in carranging in descending order array cc program ascending orderbubble sort descending order in carrange number in ascending order in csort in descending order in cc code for sorting array in descending ordernumbr sorting using chow to sort an array in ascending order in carray in ascending order in cnumber ascending order cc program to sort array elements in ascending or descending orderarrangement in descending order program on csorting number with cwrite a program that prints out all the numbers from 100 to 1 in descending order in csort array in decending order in c4 sort the numbers in ascending and descending order in c programc program to find descending orderprogram to sort an array in descending order in cdescending order of arrayascending in csorting array in descending ordersort number ascending c program sorting items in an array in descending orderc program to arrange n numbers in ascending orderselection sort in descending order in cc program to sort a set of numbers in ascending orderc program to sort an array in ascending and descending ordersorting element in ascending order using function in chow to arrange array in descending order in carray sorting in c des write a c program to sort a set of numbers in ascending and descending orderarrange 4 numbers in descending order in c without using arrayc program for selection sort in descending orderarrange the array in ascending order in cc sort array in ascending order arrange in ascending order in cc program to sort n numbers in descending ordersort in descending order array linux c languagearrange he numners in assending order cc sorting numberswrite a c program to sort a string array in ascending orderi sorted them in descending ordernumber sort in csort numbers in c programsort array in c descendingsort array elements in descending orderdescending order c programsort in decending chow to make number ascending in cfor descending carrange numbers in ascending order in array in cdescending sort in cwrite a c program to find ascending orderdescending order sorting in cdescending order array in cc program to arrange the given set of numbers in ascending and descending ordersort elements in ascending order c functionsort array in descending order in csort number c programascending order descending order program in carrange 4 numbers in descending in cc program to sort in descending orderc sort int array descendinggiven 3 integer values 2c arrange the 3 in ascending order in cdecreasing order sort in cc program for sorting array in descending orderc program to arrange a list of integers in ascending order in merge sorthow to rank array by sorting it in descending order in carrange numbers in descending order in cmethod of ascending order in carrange numbers in ascending descending order using arrays in carray ascending order in csort an array in descending order in carrenge number in array in descending ordersort in ascending order in cascending order in c programprint numbers in ascending order in cc programming sorting numbers in descending orderc program that print n numbers in descending orderhow to order numers in carrange numbrs in ascending order in cwrite a c program to sort given 10 numbers in ascending orderprint numbers in the descending in cc program that takes 10 values in an array and display them in ascending orderascending order program in c c language to input 20 numbers and arrange the numbers in ascending ordersort the array in descending orderarrange numbers in ascending order in cc program to arrange numbers in ascending orderc program to arrange numbers in descending orderarrange 3 numbers in ascending order in cdigits ascending order chow to print numbers in descending order in cc program to arrange any ten numbers in ascending order using arraysort the array in ascending order in cc function to sort an array in descending ordersort ascending order in csort array elements in ascending order in c standard methodarrange the digits of a number in descending order in cc array descending orderwrite a program to sort elements of an array in descending orderbubble sort array in descending order in cascending descending in cc program to arrange numbers in descending order using if elseprinting ascending and descending order of n numbers in cwrite a c program containing an array of 10 elements in ascending orderarrange numbrs in ascending order in c