write a program to sort the elements in a given array in c
language

Answer Posted / balaji

#include<stdio.h>
#include<conio.h>
main()
{
int temp,i,j,n=10;
int arr[n];
clrscr();
printf("\n\tEnter The Values into array");
for(i=0;i<n;i++){
printf("\n Enter Element no %d: ",i);
scanf("%d",&arr[i]);}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(arr[j] > arr[j+1]){
temp=arr[j];
arr[j]=arr[j+1];
arr[j]=temp;}
}}
printf("\n-- Sorted Series --");
for(i=0;i<n;i++){
printf("\t %d",arr[i]);}
getch();
}

Is This Answer Correct ?    16 Yes 27 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is "Hungarian Notation"?

633


How will you write a code for accessing the length of an array without assigning it to another variable?

611


Tell me the use of bit field in c language?

624


What is the best way to store flag values in a program?

576


Explain the red-black trees?

602






Why static is used in c?

616


What is bash c?

552


Differentiate between the expression “++a” and “a++”?

697


How many levels of pointers can you have?

695


What is array within structure?

578


What is a string?

664


Explain c preprocessor?

678


How do I swap bytes?

626


explain what are pointers?

615


What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25

1490