Enter 10 number using array and display it in ascending order Using Pointer in C Language


void main()
{
 int no[10],i,j,*temp;
 clrscr();

 printf("enter 10 no:");
 for(i=0;i<=9;i++)
 {
  scanf("%d",&no[i]);
 }

 printf("\nascending:");
 for(i=0;i<=9;i++)
 {
  for(j=0;j<=9;j++)
  {
   if(*(no+i)<*(no+j))
   {
    *temp=*(no+i);
    *(no+i)=*(no+j);
    *(no+j)=*temp;
   }
  }
 }
 for(i=0;i<=9;i++)
 {
  printf("\n%d",no[i]);
 }
 getch();
}



Output:
Enter 10 Number:
2
5
8
9
6
3
4
7
1
10

Ascending Order:

1
2
3
4
5
6
7
8
9
10



Enter 10 number using array and display it in ascending order Using Pointer in C Language Enter 10 number using array and display it in ascending order Using Pointer in C Language Reviewed by Unknown on 7:56:00 PM Rating: 5

No comments:

Powered by Blogger.