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 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. The area under a curve between two points can b


Study the given hierarchical class diagram and additional information, and answer the questions that follow: Sale Company: string unitPrice: double

Threaded binary tree: Consider the linked illustration of a binary tree 'T.  Approximately half of the entries is the pointer fields 'LEFT' and 'RIGHT' will have null elements. Th

I would like to get you to collaborate in my project. We want a C programmer to Develop applications for Windows, the first application may be an Instant messenger encrypted in a w

Returning References from Functions Just as in passing the parameters by reference, returning a reference also doesn't return back a copy of the variable , instead an alias is

Many modern cryptography algorithms require two numbers that are coprime, or sometimes referred to as relatively prime. Two numbers are coprime if their greatest common divisor is

how is it made

Problem Write a program in C++ to read N numbers in an array, the user should be able to search a particular number in the array using sequential search algorithm. Writing a

Q-What happens while a function throws an exception which was not specified through an exception specification for this function? A: Unexpected() is called, which, by default, w