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

#title prime number or not, to find prime numbers upto any number say "n" e...

to find prime numbers upto any number say "n" entered by user

Write a program to compute the equation, Write a program to compute the fol...

Write a program to compute the following equation for values of time.           y = 2x+3   The values of time are stored in the file program.dat and the solution should be display

Program of 2d byte array dynamicall, In this lab, please complete a given p...

In this lab, please complete a given program to perform the following tasks: 1. Allocate a 10 by 5 2D byte array dynamically. The way of allocation must be consistent with page

Simple object-oriented program, This assignment is to be undertaken individ...

This assignment is to be undertaken individually - no group work is permitted. Background information This assignment is an exercise in simple object-oriented programming and, acco

I want rss feed from emails, Project Description: I am trading binary op...

Project Description: I am trading binary options and need my signals that are sent to me via email to be sent to my followers via an RSS feed I have no idea how rss feeds imp

Described assignment operator?, Default assignment operator mange assigning...

Default assignment operator mange assigning one object to another object of the same class. It is member to member copy as shallow copy.

What are literals, Literals (Constants) Constants are data storage loca...

Literals (Constants) Constants are data storage locations whose address is not accessible for the user. Their value is not altered during the course of the program. Literal

Program to display stock containing item code, THIS PROGRAM IS TO DISPLAY A...

THIS PROGRAM IS TO DISPLAY A STOCK CONTAINING ITEM CODE,ITEM NAME,PRICE AND ANOTHER STOCK WITH CODE & QUANTITY AND DISPLAY COMPLETE INFORMATION #include #include #include

#CompilerRelated, #C Why don''t online compilers support the header file?...

#C Why don''t online compilers support the header file? What can I do to resolve this? PS. I have tried , does''nt work either. Thannk in advance.

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