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


Please Help Members By Posting Answers For Below Questions

Write a factorial program using C.

637


What are actual arguments?

641


I have a varargs function which accepts a float parameter?

573


What is difference between union All statement and Union?

628


What are structure types in C?

658






What is const volatile variable in c?

570


Is it better to use malloc() or calloc()?

643


Write a program to print “hello world” without using semicolon?

667


Multiply an Integer Number by 2 Without Using Multiplication Operator

314


How we can insert comments in a c program?

623


all c language question

1862


Write a c program to build a heap method using Pointer to function and pointer to structure ?

4169


There seem to be a few missing operators ..

611


what is the significance of static storage class specifier?

1653


What is a pragma?

662