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

What is wild pointer in c?

1069


What library is sizeof in c?

1085


How can you return multiple values from a function?

1113


How was c created?

1049


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

1095


How do you determine whether to use a stream function or a low-level function?

1122


Why is c used in embedded systems?

1114


What are multibyte characters?

1115


Why main function is special give two reasons?

1537


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

1053


Differentiate between a structure and a union.

1288


pierrot's divisor program using c or c++ code

2238


Process by which one bit pattern in to another by bit wise operation is?

1156


What is 02d in c?

1072


What is a structure and why it is used?

1218