write a program of bubble sort using pointer?
Answer Posted / gulam md gouss khan
#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\n press 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 ? | 19 Yes | 12 No |
Post New Answer View All Answers
What is a null pointer in c?
What is array of pointers to string?
Which is the best website to learn c programming?
What is c language and why we use it?
Write a program to print all permutations of a given string.
What does == mean in texting?
How many types of arrays are there in c?
How do I round numbers?
What is bin sh c?
Why do we need functions in c?
How #define works?
What is NULL pointer?
Which programming language is best for getting job 2020?
Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014 Npu university
Explain what is the concatenation operator?