adds


Ascending order of given numbers by C++ :

AIM:
To find ascending order of a given set of numbers by using C++ Programme.

REQUISITES:

A PC or laptop, Turbo C++ compiler installed in it.

THEORY:
Ascending order means the increasing order of the given numbers.
ex: 1, 4, 5, 8, 9 etc.

CODING:
#include<iostream.h>
#include<conio.h>
void main()
{
int n,a[100],i,j,temp;
clrscr();
cout<<"Enter your input for n:";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter a number:";
cin>>a[i];
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if (a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
cout<<"The numbers in ascending order is:\n"<<endl;
for(i=0;i<n;i++)
{
cout<<endl<<a[i];
}
getch();
}
OUTPUT:

Model syllabus (+3)Downoad

List of all practicals:   Download

Get all Books:  Download
Physics Notes: CLICK

IIT-JAM             JEST                GATE               NET
                                                           
  • How to Prepare for IIT-JAM  ⇠ ⇠ Click Here
Get everything about your B.Sc (+3) Physics Practical⇠ ⇠Click

Post a Comment

Previous Post Next Post