| | |
What is wrong?..!
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
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
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
C++ Syntax (Toggle Plain Text)
#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();
Hey this is the new code.. Is there anything wrong with this one? I missed the ELSE and a few {}
C++ Syntax (Toggle Plain Text)
#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]; } else if(a[i]<min) { min=a[i]; } cout<<"Largest is "<<max<<" and Smallest is "<<min; getch(); }
![]() |
Similar Threads
- My CD-RW plays but won't burn. What could be wrong?? Help Please? (Storage)
- Retrieve email I sent to the wrong person (Web Browsers)
- Ram voltage wrong?? (Motherboards, CPUs and RAM)
- Am I going about this the wrong way (IT Professionals' Lounge)
- wats wrong with imesh??? (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Help on fscanf
- Next Thread: Copy a Folder
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector visualstudio win32 windows winsock word wordfrequency wxwidgets






