C program to arrange the given numbers in ascending order using pointers

Posted Date:     Total Responses: 0    Posted By: Sunil Reddy   Member Level: Gold   Points/Cash: 2   

int i,j,number,temp,*myptr,numbers[20];
printf(“\nEnter the number of elements in the array : “);
for (i=0; i < number; i++)
printf(“\nEnter number[%d] : “,i);
printf(“\nThe array is : “);
myptr = numbers;
for (i=0; i < number; i++)
printf(“%d, “,*myptr++);
myptr = numbers;
for (i=0; i < number - 1; i++)
for (j = i; j < number; j++)
if (*(myptr+i) > *(myptr+j))
temp = *(myptr+i);
*(myptr+i) = *(myptr+j);
*(myptr+j) = temp;
printf(“\nThe sorted array is : “);
myptr = numbers;
for (i=0; i < number; i++)
printf(“%d, “,*myptr++);

Project Feedbacks

No feedbacks found. Be the first to respond...

Post Feedback
You must Sign In to post a feedback.
Next Project: C program, using pointer for string comparison
Previous Project: C program for quick sort

Return to Project Index

Post New Project

Related Projects

Top Contributors
TodayLast 7 Daysmore...

Awards & Gifts

Online Members

K Mohan
ISC Technologies, Kochi - India. © All Rights Reserved.