Sunday, April 5, 2020

c program to sort n numbers in ascending order | C Programming Example

 C Program Example To Sort Given Number In Ascending Order Without Variable

This Article From Learn c programming in Hindi Will help you to learn To Sort Given Number In Ascending Order, C programming language Example and check out "selection sort program in c", "socket programming in c", "merge sort program in c","Kruskal's algorithm in c", "for loop c programming", "c struct example","simple program in c language", "simple CPP program", "c programming practice questions", "c program using for loop", "programming using c", "hello world program in c", "if statement in c ".

C Programming Example
C Programming Example


नीचे दी गई संख्याओं को आरोही क्रम में क्रमबद्ध करने के लिए C Program Example है। यह तर्क को क्रमबद्ध करने वाले अवरोही क्रम के समान है। तर्क में <(इससे कम) के बजाय बस> (अधिक से अधिक) का उपयोग करें।

Source Code For C Program Exaple


#include <stdio.h>
 
int main ()
 
{
 
   //int i,j,a,n,number[15];
 
     int i,j,a,n=5,number[15];
 
   /*
 
       printf ("\nPlease enter how many numbers you want to sort");
 
       scanf (""%d"", &n);
 
       printf ("\nPlease enter the numbers to be sorted as ascending order");
 
       for (i=0; i number[j])
 
     {
 
       a= number[i];
 
       number[i] = number[j];
 
       number[j] = a;
 
     }
 
   }
 
 }
 
 printf ("\nAscending order of entered numbers");
 
for (i=0; i<n; ++i)
 printf ("\n%d",number[i]);
}

OUTPUT


Ascending order of entered numbers

1

3

4

6

7

C Program Example To Sort Given Number In Ascending Order With Variable


#include 
 
int main ()
 
{
 
     int i,j,a,n=5,number[15];
 
       printf ("\nPlease enter how many numbers you want to sort");
 
       scanf (""%d"", &n);
 
       printf ("\nPlease enter the numbers to be sorted as ascending order");
 
       for (i=0; i number[j])
 
     {
 
       a= number[i];
 
       number[i] = number[j];
 
       number[j] = a;
 
     }
 
   }
 
 }
 
 printf ("\nAscending order of entered numbers");
 
for (i=0; i<n; ++i)
 printf ("\n%d",number[i]);
}

Output


Numbers will be sorted in ascending order based on your entered numbers.

0 Comments:

Post a Comment