C program for maximum no, minimum no and sorting, C/C++ Programming

  C Program for MAXIMUM NO, MINIMUM NO AND SORTING

 

void main()

{

          int i,j,t;

          int a[5];

          clrscr();

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

          {

                   printf("ENTER THE SINGLE DIGIT= ");

                   flushall();

                   scanf("%d",&a[i]);

          }

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

          {

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

                   {

                             if(a[i]>a[j])

                             {

                                      t=a[i];

                                      a[i]=a[j];

                                      a[j]=t;

                             }

                   }

          }

          printf("\n");

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

          {

                   printf(" %d",a[j]);

          }

          printf("\nTHE MAXIMUM NUMBER IS %d\n",a[5]);

          printf("THE MINIMUM NUMBER IS %d\n",a[0]);

          getch();

}

 

OUTPUT :

ENTER THE SINGLE DIGIT : 5

ENTER THE SINGLE DIGIT : 8

ENTER THE SINGLE DIGIT : 1

ENTER THE SINGLE DIGIT : 2

ENTER THE SINGLE DIGIT : 6

8 6 5 2 1

THE MAX. NO IS : 8

THE MIN.  NO IS : 1

 

Posted Date: 9/10/2012 2:24:24 AM | Location : United States







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

Write discussion on C program for maximum no, minimum no and sorting
Your posts are moderated
Related Questions
a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits of a and b.

A: Depends. Might be "zero" Objects which are thrown must have a publicly accessible copy-constructor. The compiler is permitted to generate code which copies the thrown object

c program to construct a structure: struct sensus                 {                                 char name[30];                                 long int population;

Question: (a) Write down the class 'ListNode' to contain the following:- (i) variable data of type Object (ii) variable next of type ListNode (iii)

You are setting up an information system for a DVD Rental Company called Box office. The new system need to hold information about customers and DVDs rentals, payments and fines. C

What is the difference among a copy constructor and an overloaded assignment operator? Ans) A copy constructor constructs a latest object by using the content of the argument

How do one throw polymorphically?               A: Sometimes people write code such as: class MyExceptionBase { }; class MyExceptionDerived : public MyExceptionBase { };

Write a program to get the largest element in an array using Function? # include int largest(int b[],int); main() { int lar,a[5]={12,2,36,40,5}; lar=largest(a,n); printf("

Within C we access external devices by means of a pointer i.e. address. The address could point to any memory mapped device i.e. Ram, Rom, Duart, Disk drives etc. Therefore there i

Using your mountain project source code as a starting point, you are to write a code that randomly chooses one of the triangles on the surface of your mountain, this will be the en