How to write a c program to accept n numbers from user,store these numbers into an array & sort the number of an array in C Programming Language ?
Solution:
/*C program to accept n numbers from user,store these numbers into an array & sort the number of an array*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,j,t;
clrscr();
printf("\nEnter the n no of array: ");
scanf("%d",&n);
printf("\nEnter the array elements: ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
a[0]>a[1];
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("\nArray in ascending order:\t ");
for(i=0;i<n;i++)
{
printf("%d",a[i]);
}
printf("\nArray in descending order:\t ");
for(i=n-1;i>=0;i--)
{
printf("%d",a[i]);
}
getch();
}
//OUTPUT:-
//Enter the n no of array: 4
//Enter the array elements: 4 3 2 1
//Array in ascending order: 1 2 3 4
//Array in descending order: 4 3 2 1
Learn More :
Accept
- C Program to accept n numbers from user & find out the maximum element out of them by using dynamic memory allocation
- C Program to accept string from user & convert all lower case letters into upper case letters & vice versa
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- C Program to accept n numbers & store all prime numbers in an array & display this result
- C program to accept n number from user,store these numbers into an array & count the no of occurrences of each number
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- C Program to accept a string from user, delete all vowels from that string & display the result
- Write a c program to accept a string from user & generate following pattern (e.g, input "abcd")
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user, store these numbers into an array. Find out Maximum & Minimum number from an Array
- C Program to accept data from user store that data into text file
- Accept n number from user, store these number into an array and calculate the average of n number
Enter by User
- C Program to Enter an ODD number between 1 and 49.
- C Program to Calculation of One Number Raised to Another
- C Program to Count Vowels, Consonants and Spaces in a string
- C Program to calculate Area, Perimeter of Rectangle; Area, Circumference of Circle.
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- C Program to find result where value and power are user given
- C Program That in a Given Natural Number x Insert Figure c at Position p
- C Program To Find Prime Number And If Number Is Not Prime Then Find Factors
- C program that lets the user choose if he wants to add a item to the shopping list or print it out
- C Program that prompts the user to input a string, (whitespaces allowed)
- C Program to Input Number by the user between 1-100
- How to Gets User Input For Height in C Programming
- Loudness Program: Gets loudness level from user; chooses a response And prints it using logical and operative statements
- C Program Exchange User Entered Text Between 2 Modules
- C Program to accept n numbers from user & find out the maximum element out of them by using dynamic memory allocation
- C Program to accept string from user & convert all lower case letters into upper case letters & vice versa
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- C program to accept n number from user,store these numbers into an array & count the no of occurrences of each number
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- C Program to accept a string from user, delete all vowels from that string & display the result
- Write a c program to accept a string from user & generate following pattern (e.g, input "abcd")
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user, store these numbers into an array. Find out Maximum & Minimum number from an Array
Sort
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program Sort Example
- C Program Shell Sort Using C Programming Language
- C Program Selection Sort Using C Programming Language
- C Program to Bubble Sort Using C Programming Language
- C Program Insertion Sort Using C Programming Language
- Heap Sort Using C Programming Language
- C Program To Sort An Array In Ascending And Descending Order
- C Program To Sort An Array Of Names In Alphabetical And Reverse Order
- C Program Sort Array By Segment
- C Program to sort an array using bubble sort
- C Program to merge and sort two arrays
- Un-sortiertes Array and Sortiertes Array
- matrix sort in C Program
- C program that receives 10 float numbers from the console and sort them in non-ascending order, and prints the result
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to Implement Quick Sort
- QuickVSInsertion Sorting C Program
Store
- C Program To Store Students Record In A Text File
- C Program To Store Students Record Using Structure
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- C Program to accept n numbers & store all prime numbers in an array & display this result
- C program to accept n number from user,store these numbers into an array & count the no of occurrences of each number
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user, store these numbers into an array. Find out Maximum & Minimum number from an Array
- C Program to accept data from user store that data into text file
- Find the union and intersection of two sets of integer store it in two array C Program
- Accept n number from user, store these number into an array and calculate the average of n number
- C Program - Hash Table to store information about a student
- C Program to Input Student Details into a File For Two Subjects
Array
- How to pass one dimensional array to function in c.
- Write a c program which passes two dimension array to function.
- C Program Array Index Example
- C Program Array Example: Average
- C Program Array Example: Reverse
- C Program Array Example
- C Program to Array
- C Program Array NxM Elements Geometric/Arithmetic
- C Program To Find The Maximum And Minimum Value In An Array
- C Program To Find Union & Intersection Of Two Array
- C Program To Search A Number Inside The Array
- C Program To Sort An Array In Ascending And Descending Order
- C Program To Sort An Array Of Names In Alphabetical And Reverse Order
- C Program To Copy One Character Array Into Another
- Returns: array of decoded values. [0] - count of values
- C Program to Check if a number is in an array[1000]
- C Program to Find max and min in array using pointer concept
- C Program Sort Array By Segment
- C Program to sort an array using bubble sort
- C Program to find smallest in an array using pointer
- C Program to merge and sort two arrays
- Un-sortiertes Array and Sortiertes Array
- C Program to Array Deserialization
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- Input reads in the array positions and range for random generation.
Number
- Find out the perfect number using c program
- Write a c program to find out H.C.F. of two numbers.
- Check the given number is armstrong number or not using c program.
- Write a c program to find largest among three numbers using conditional operator
- FIND OUT GENERIC ROOT OF A NUMBER - C PROGRAM.
- FIND PRIME FACTORS OF A NUMBER USING C PROGRAM
- How To Write a C program that generates two random numbers ?
- Write a C program to find maximum or equal between two numbers ?
- How to Write a C program to find maximum between two numbers ?
- Write a C program to perform math operations on two input whole numbers. The operations are:
- Write a C program to find maximum between three numbers ?
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program to Enter an ODD number between 1 and 49.
- C program acquires keyboard 10 numbers for each of these numbers to determine if it is a first issue, by printing immediately message should at the end, if none of the numbers you entered was a first issue, print an appropriate message.
- C program generates a random number and uses an algorithm to generate 9 other numbers.
- C Program to Find Random Number
- C Program To Find LCM and HCF Of Two Number Using Function - 2
- C Program to find LCM and HCF Of Two Number Using Recursion - 3
- C Program To Find LCM and HCF Of Two Number -1
- C Program To Find Reverse Of Any Digit Number
- C Program To Find The Frequency Of A Number
- C Program To Print Prime Numbers Upto The Number You Want
- C Program To Print Sum Of n Digit Number
- C Program To Reverse A Number
- C Program To Search A Number Inside The Array
n
- C Program to Sum of The First and Last Digit Of 'n' Digit Number
- A small I/O bound program to copy N bytes from an input file to an output file.
- C Program to Calculate the mathematical expression for the first n numbers
- C Program to accept n numbers from user & find out the maximum element out of them by using dynamic memory allocation
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- C Program to accept n numbers & store all prime numbers in an array & display this result
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- Accept n number from user, store these number into an array and calculate the average of n number