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
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
What is a char c?
Explain how do you use a pointer to a function?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
What does %d do in c?
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
What is pointer to pointer in c language?
What is operator promotion?
What is advantage of pointer in c?
What is LINKED LIST? How can you access the last element in a linked list?
Wt are the Buses in C Language
If you know then define #pragma?
What is function prototype in c language?
What is the scope of static variable in c?