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 of bubble sort using pointer?

Answer Posted / nitish-csedu

#include<stdio.h>
int main()
{
int n,i,j,temp,a[1000],*p;
scanf("%d",&n);
p=&a[0];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(*(p+i)>(*(p+j)))
{
temp=*(p+i);
*(p+i)=*(p+j);
*(p+j)=temp;
}
}
}
for(i=0;i<n;i++)
{
printf("%d ",*(p+i));
}
return 0;
}

Is This Answer Correct ?    10 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there any demerits of using pointer?

1015


write a program to print largest number of each row of a 2D array

2268


why we wont use '&' sing in aceesing the string using scanf

2311


What is c definition?

1195


What does dm mean sexually?

1261


Explain how are portions of a program disabled in demo versions?

1074


will u please send me the placement papers to my mail???????????????????

1794


What is scope rule of function in c?

1030


What is assert and when would I use it?

963


What are the key features in c programming language?

1005


What is call by value in c?

953


What does the c in ctime mean?

1018


explain what are pointers?

968


What are predefined functions in c?

1022


Is the exit() function same as the return statement? Explain.

1036