adds


Smallest of given 'n' numbers & its location:


AIM:
To find the smallest of given 'n' numbers & its location.

THEORY:
The smallest number in list of numbers is a number which has the smallest value as compared to the other values in that list.
The smallest of ‘n’ numbers & its location /position can be found by C++  using the following codes.

CODING:

#include<iostream.h>
#include<conio.h>
void main()
{
int a[25],n,i,p=0,m;
clrscr();
cout<<"Enter a number:";
cin>>n;
cout<<"Enter " ""<<n<<"numbers:"<<endl;
for(i=0;i<n;i++)
{
cin>>a[i];
}
m=a[0];
for(i=0;i<n;i++)
{
if (m>a[i])
{
m=a[i];
p=i;
}
}
cout<<"Smallest number is:"<<m<<endl;
cout<<"The position of smallest  no. is:"<<p+1<<endl;
getch();
}
OUTPUT:



Model syllabus (+3)Downoad

List of all practicals:   Download

Get all Books:  Download

Syllabus For:                                                      Get all B.Sc Physics Notes
                                                                                         CLICK

IIT-JAM                                                               


  • How to Prepare for IIT-JAM  ⇠ ⇠ Click Here

Post a Comment

Previous Post Next Post