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   


#include
main()
{
int i,j,number,temp,*myptr,numbers[20];
printf(“\nEnter the number of elements in the array : “);
scanf(“%d”,&number);
for (i=0; i < number; i++)
{
printf(“\nEnter number[%d] : “,i);
scanf(“%d”,&numbers[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


Complete the action items below to enter to win an iPad Mini from India Study Channel! in India Study Channel - Locker on LockerDome
Awards & Gifts
Active Members
TodayLast 7 Daysmore...

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