C program for sorting, C/C++ Programming

Assignment Help:

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();

}

 

 


Related Discussions:- C program for sorting

Console atm machine coding, construct a console programme for a bank ATM m...

construct a console programme for a bank ATM machine.

Explain about the constants in c language, Explain about the Constants in c...

Explain about the Constants in c language? The Constants in C refer to fixed values that don't change during the execution of a program. C has four fundamental types of constan

Data types, #question write a prog c & cpp

#question write a prog c & cpp

Vb.net, write a program that would accept the radius of the sphere and retu...

write a program that would accept the radius of the sphere and return its surface area.

Simple program of c++ , Simple program of c++: int main() {    i...

Simple program of c++: int main() {    int   bushels;    float dollars, rate;                 cout                 cin >> dollars;                 cout

Area under curve, write a program to find the area under curve y=f(x) betwe...

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

String, A string is said to be "Beautiful"€, if it contains only non repet...

A string is said to be "Beautiful"€, if it contains only non repetitive alphabets

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd