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 are local variables c?
What is strcmp in c?
Write a program in c to replace any vowel in a string with z?
Are the outer parentheses in return statements really optional?
Is calloc better than malloc?
What is wild pointer in c with example?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
Where is volatile variable stored?
What is the code in while loop that returns the output of given code?
What is a char in c?
Where is c used?
How many data structures are there in c?
What does the characters “r” and “w” mean when writing programs that will make use of files?
What is the general form of function in c?
What are the similarities between c and c++?