write a program of bubble sort using pointer?
Answer Posted / anuj pratap singh
#include<stdio.h>
#include<conio.h>
void sort(int *,int );//prototype
void main()
{
int a[5],size=5; //let suppose
int i;
clrscr();
printf("Enter the elements according to size:");
for(i=0;i<size;i++)
{
scanf("%d",&a[i]);
}
sort(a,size); //calling function
printf(\n\npress any key to exit);
getch();
}
void sort(int *p,int size) //called function
{
int i,j,temp;
for(i=0;i<size-1;i++)
{
for(j=0;j<size-i-1;j++)
{
if(*(p+J)>*(p+j+1))
{
temp=*(p+J);
*(p+J)=*(p+J+1);
*(p+J+1)=temp;
}
}
}
for(i=0;i<size;i++)
{ pritf("%d",*(p+i));
}
}
| Is This Answer Correct ? | 40 Yes | 14 No |
Post New Answer View All Answers
Is it fine to write void main () or main () in c?
Which is an example of a structural homology?
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
What is the difference between array and linked list in c?
how is the examination pattern?
What is main function in c?
How do you determine the length of a string value that was stored in a variable?
Why doesnt that code work?
How do I round numbers?
Explain what are header files and explain what are its uses in c programming?
Explain what is wrong with this statement? Myname = ?robin?;
Explain the meaning of keyword 'extern' in a function declaration.
What is the purpose of & in scanf?
How do you list files in a directory?
Differentiate between full, complete & perfect binary trees.