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 FIFO?
What is a nested loop?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
Why is c so important?
How do I determine whether a character is numeric, alphabetic, and so on?
Write a code to generate a series where the next element is the sum of last k terms.
Write a program to print all permutations of a given string.
What functions are in conio h?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What is void pointers in c?
What is string function in c?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
Explain goto?
What is a string?