write a program to arrange the contents of a 1D array in
ascending order

Answer Posted / rajeev

#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,temp;
clrscr();
printf("\n enter the size of the array");
scanf("%d",&n);
printf("\n enter the contents of the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<(n-1)-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
getch();
}

Is This Answer Correct ?    10 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the size of structure pointer in c?

840


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1748


What are the parts of c program?

877


Explain spaghetti programming?

983


Can 'this' pointer by used in the constructor?

847


What is the condition that is applied with ?: Operator?

910


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

790


In which language linux is written?

952


What is actual argument?

855


What is a program?

946


Explain how do you determine the length of a string value that was stored in a variable?

940


What are the types of data types and explain?

886


Which driver is a pure java driver

1296


One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

2444


hi, which software companys will take,if d candidate's % is jst 55%?

1893