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
What is "Hungarian Notation"?
How will you write a code for accessing the length of an array without assigning it to another variable?
Tell me the use of bit field in c language?
What is the best way to store flag values in a program?
Explain the red-black trees?
Why static is used in c?
What is bash c?
Differentiate between the expression “++a” and “a++”?
How many levels of pointers can you have?
What is array within structure?
What is a string?
Explain c preprocessor?
How do I swap bytes?
explain what are pointers?
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