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
What are the 4 types of unions?
Explain how can I convert a number to a string?
What are global variables and how do you declare them?
explain how do you use macro?
Explain about block scope in c?
How can I do graphics in c?
What is restrict keyword in c?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
What is static identifier?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
What is .obj file in c?
Explain about the functions strcat() and strcmp()?
Explain how do you use a pointer to a function?
How are variables declared in c?