| | |
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 arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






