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
How can I read and write comma-delimited text?
What are the three constants used in c?
#include
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
What is a shell structure examples?
How can I get back to the interactive keyboard if stdin is redirected?
What is array in c with example?
Where register variables are stored in c?
Explain void pointer?
What is the use of ?: Operator?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
what is bit rate & baud rate? plz give wave forms
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
Differentiate between new and malloc(), delete and free() ?