Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / poornima

int main()
{
int a[20],n,i,j,temp;
printf("Enter the size of an array : ");
scanf("%d",&n);
printf("Enter the array elements : ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
printf("\nAscending Order\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
return 0;
}

Is This Answer Correct ?    65 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

All technical questions

1992


What is structure padding and packing in c?

1073


What is the heap?

1221


Is c is a middle level language?

1070


Is struct oop?

1015


Difference between goto, long jmp() and setjmp()?

1182


What is scanf_s in c?

1125


Explain how can you avoid including a header more than once?

1093


What is extern variable in c with example?

998


What is the return type of sizeof?

1067


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

2186


Explain the difference between structs and unions in c?

1028


Explain what standard functions are available to manipulate strings?

1078


What is scope and lifetime of a variable in c?

1077


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

2260