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 / kameshav

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]);
}
printf("\nAscending Order\n");
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("%d\n",a[i]);
}
return 0;
}

Is This Answer Correct ?    23 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

int i=10; printf("%d %d %d", i, i=20, i);

1624


Write a code to generate a series where the next element is the sum of last k terms.

1229


What is the use of bitwise operator?

1132


Explain how does flowchart help in writing a program?

1119


What is substring in c?

1207


What is the difference between local variable and global variable in c?

1235


In C programming, how do you insert quote characters (‘ and “) into the output screen?

1531


How do you print only part of a string?

1023


What is the explanation for the dangling pointer in c?

1117


Which header file should you include if you are to develop a function which can accept variable number of arguments?

1401


Explain how do you override a defined macro?

1078


What are different storage class specifiers in c?

1096


What is the meaning of ?

1040


What are the types of macro formats?

1125


explain what is an endless loop?

1093