Just because something is syntactically accurate doesn't mean "there is nothing wrong with the code." An important thing to mention about code, is that you are supposed to make it easy to read. Just because "it compiles fine" doesn't mean another programmer can look at it, and decipher your code without major effort. Some of these things include proper indentation. Indentation allows someone to see which blocks of code fall under which conditions and loops. It is meant to simplify the debugging process, and make life easier for you later on, and any other programmers who might work on your code. I'll wager that Salem's comment, wasn't merely a quick fix to a problem, it was meant to address a much deeper issue as well, such as the entirety of the style. I'll guess it should look something more like:
#include <iostream.h>
#include <conio.h>
using namespace std;
int main(int argc, char **argv)
{
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];
} else if(a[i]<min) {
min=a[i];
}
}
}
cout<<"Largest is "<<max<<" and Smallest is "<<min;
getch();
return 0;
}
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Offline 2,413 posts
since Dec 2004