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
Is there any demerits of using pointer?
write a program to print largest number of each row of a 2D array
why we wont use '&' sing in aceesing the string using scanf
What is c definition?
What does dm mean sexually?
Explain how are portions of a program disabled in demo versions?
will u please send me the placement papers to my mail???????????????????
What is scope rule of function in c?
What is assert and when would I use it?
What are the key features in c programming language?
What is call by value in c?
What does the c in ctime mean?
explain what are pointers?
What are predefined functions in c?
Is the exit() function same as the return statement? Explain.