Largest among 'n' numbers & its location by C++:
AIM:
To find Largest among n numbers & its location by using C++ Programme.
REQUISITES:
A PC or laptop, Turbo C++ compiler installed in it.
THEORY:
The
greatest number in list of numbers is a number which has the greatest value as
compared to the other values in that list.
The
largest 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<<"Largest number is:"<<m<<endl;
cout<<"The position of lagesrt no.
is:"<<p+1<<endl;
getch();
}
OUTPUT:
Model syllabus (+3): Downoad
List of all practicals: Download
Syllabus For: Get all B.Sc Physics Notes
Syllabus For: Get all B.Sc Physics Notes
- How to Prepare for IIT-JAM ⇠ ⇠ Click Here
- How to prepare for JEST ⇠ ⇠ Click Here
Post a Comment