Hello friends.. I am an amateur programmer in TURBO C++ .. It is a very old version v3.0 ... I am beginner.. I wrote a very simple programme to find the largest ans smallest element in an array . .
The largest element finding process is working finely .. I added a watch on MAX and MIN... but out put MIN is wrong..! please help me Pros
Jeevan
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10],n,min,max,i;
cout<<"Enter the number of elements in the matrix \t";
cin>>n;
cout<<"enter the elements of the matrix \n";
for(i=0;i<n;i++)
cin>>a[i];
max=min=a[0];
for(i=0;i<n;i++)
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
cout<<"Largest is "<<max<<" and Smallest is "<<min;
getch();