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
What is the size of structure pointer in c?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What are the parts of c program?
Explain spaghetti programming?
Can 'this' pointer by used in the constructor?
What is the condition that is applied with ?: Operator?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
In which language linux is written?
What is actual argument?
What is a program?
Explain how do you determine the length of a string value that was stored in a variable?
What are the types of data types and explain?
Which driver is a pure java driver
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.
hi, which software companys will take,if d candidate's % is jst 55%?