C program for sorting, C/C++ Programming

C Program for SORTING

# include stdio.h>

void main()

{

          char a;

          int *p;

          int i,j,temp;

          clrscr();

          p=&i;

          p++;

          for(i=1;i<=5;i++)

          {

                   printf("Enter the %d no.",i);

                   scanf("%d",&*(p+i));

          }

printf("ENTER A FOR ASENDING OR D FOR DECENDING ORDER -");

scanf("%c",&a);

          if(a=='a')

          {

                   for(i=1;i<=5;i++)

                   {       

for(j=1;j<=5;j++)

                             {

                             if(*(p+i)<*(p+j))

                             {

                                      temp=*(p+i);

                                       *(p+i)=*(p+j);

                                      *(p+j)=temp;

                             }

                             }

                   }

          }

          else if(a=='d')

          {

                   for(i=1;i<=5;i++)

                   for(j=1;j<=5;j++)

                   {

                             if(*(p+i)>*(p+j))

                             {

                                      temp=*(p+i);

                                      *(p+i)=*(p+j);

                                      *(p+j)=temp;

                             }

                   }

          }

          printf("\nThe sorted no is.");

          for(i=1;i<=5;i++)

          {

                   printf("\n%d",*(p+i));

          }

          getch();

}

 

 

Posted Date: 9/10/2012 8:23:42 AM | Location : United States







Related Discussions:- C program for sorting, Assignment Help, Ask Question on C program for sorting, Get Answer, Expert's Help, C program for sorting Discussions

Write discussion on C program for sorting
Your posts are moderated
Related Questions
Write a c++ program to find the sum of 0.123 ? 103 and 0.456 ? 102 and write the result in three significant digits.

Question: (a) (i) Explain how class members can be accessed when using objects of the class. Use a suitable example to illustrate your answer. (ii) Explain how the privat

Define register with bit fields? We could define register simply with bit fields: struct DISK_REGISTER { unsigned ready:1; unsigned error_occured:1; unsigned disk_spinni

Access to the channel/devices is achieved by means of general purpose I/O routines Theses are standard functions described in stdio.h header file namely getc and putc. Getc and put


Exceptions. Your SVector class should throw four exceptions: 3.1. If the constructor size is invalid, then it will just allow the implicit STL bad_alloc exception to pass up to mai

Define the Processing of a Structure? The members of structure are typically processed individually as separate entities. So we must be able to access the individual structure

big-m method operation reseach in progrmme c++..

please help me get all the inbuilt functions in c++

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b