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
Write a factorial program using C.
What are actual arguments?
I have a varargs function which accepts a float parameter?
What is difference between union All statement and Union?
What are structure types in C?
What is const volatile variable in c?
Is it better to use malloc() or calloc()?
Write a program to print “hello world” without using semicolon?
Multiply an Integer Number by 2 Without Using Multiplication Operator
How we can insert comments in a c program?
all c language question
Write a c program to build a heap method using Pointer to function and pointer to structure ?
There seem to be a few missing operators ..
what is the significance of static storage class specifier?
What is a pragma?