| | |
What is wrong?..!
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
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
Views: 532 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






