#include <stdio.h>
#include <conio.h>
#define MAXSIZE 10
void main()
{
int array[MAXSIZE];
int i, j, N, temp;
clrscr();
printf(“Enter the value of N\n”);
scanf(“%d”,&N);
printf(“Enter the elements one by one\n”);
for(i=0; i<N ; i++)
{
scanf(“%d”,&array[i]);
}
printf(“Input array is\n”);
for(i=0; i<N ; i++)
{
printf(“%d\n”,array[i]);
}
/* Bubble sorting begins */
for(i=0; i< N ; i++)
{
for(j=0; j< (N-i-1) ; j++)
{
if(array[j] > array[j+1])
{
temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
printf(“Sorted array is…\n”);
for(i=0; i<N ; i++)
{
printf(“%d\n”,array[i]);
}
} /* End of main*/
/*———————————-
Output
Enter the value of N
5
Enter the elements one by one
390
234
111
876
345
Input array is
390
234
111
876
345
Sorted array is…
111
234
345
390
876
—————————*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to read N integers (zero, +ve and -ve) into an array A and to a) Find the sum of negative numbers b) Find the sum of positive numbers and c) Find the average of all input numbers Output the various results computed with proper headings
- C program to input N numbers (integers or reals) and store them in an array. Conduct a linear search for a given key number and report success or failure in the form of a suitable message
- Sample – Program to enter 10 integers in a single-dimension array and then print out the array in ascending order.
- C program to find the sum of odd numbers and sum of even numbers from 1 to N. Output the computed sums on two different lines with suitable headings
- C program to reverse a given integer number and check whether it is a palindrome. Output the given numbers with suitable message
