Wednesday, 11 February 2015

C Program to Access Elements of an Array Using Pointer in Ascending Order

#include
#include
void main()
{

int x[size], *p, *q, *r, temp,size;
clrscr();
        printf("Number of elements to be entered:");
        scanf("%d",&size);
p=x;
for(q=p; q
{
printf("\nEnter value:");
scanf("%d", q);
}
printf("\n\nkush\n");
printf("\n\nPrinting the elements in asceding order.......\n");
for(q=p; q
{
for(r=q+1; r
{
if(*q>*r)
{
temp=*q;
*q=*r;
*r=temp;
}
}
}
for(q=p; q
{
printf("%d ", *q);
}
getch();
}

No comments:

Post a Comment