6 Replies - 1815 Views - Last Post: 24 December 2011 - 03:04 PM Rate Topic: -----

#1 sisieablebeable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 14-December 11

how i want to find the max and min value in array?

Posted 14 December 2011 - 07:01 PM

//anyone please help me to settle this
# include <iostream>

using namespace std;
//const int values = 30;

int main ()
{
int sum=0;
int num[5],max,min;
float average;

cout << "Please enter 5 numbers to get the sum : \n ";

for (int i=0; i<5; i++)
{
cin >> num[i];
}

int j=0;
while (j<5)
{
sum += num[j];
j++;
} 

cout << "Sum : " << sum<<endl;

average = sum/5;
cout<<"average :"<<average<<endl;

for (int i=0; i<5; i++)
{
if (i[j]< max)  //something wrong with this

 max = i[j];

}
 else if (j[i]<min)
{
 min = j[i];
 
 
 cout<<"max:"<<max<<endl;
 cout<<"min:"<<min<<endl;
}
return 0;
}


:code:

This post has been edited by jimblumberg: 14 December 2011 - 07:02 PM
Reason for edit:: Added missing Code Tags, Please learn to use them.:code:


Is This A Good Question/Topic? 0
  • +

Replies To: how i want to find the max and min value in array?

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5537
  • View blog
  • Posts: 11,866
  • Joined: 02-June 10

Re: how i want to find the max and min value in array?

Posted 14 December 2011 - 07:04 PM

HINT:

Your comparison on line 33 and on 38 are using the same operator of less than.

Since one is trying to find the min and one is trying to find the max then both comparisons can't be the same, can they?
Was This Post Helpful? 0
  • +
  • -

#3 sisieablebeable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 14-December 11

Re: how i want to find the max and min value in array?

Posted 22 December 2011 - 11:20 PM

View PosttlhIn`toq, on 14 December 2011 - 07:04 PM, said:

HINT:

Your comparison on line 33 and on 38 are using the same operator of less than.

Since one is trying to find the min and one is trying to find the max then both comparisons can't be the same, can they?

ok..thanks for helping :)
Was This Post Helpful? 0
  • +
  • -

#4 sisieablebeable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 14-December 11

Re: how i want to find the max and min value in array?

Posted 22 December 2011 - 11:25 PM

how i can improve my coding..?
and please show me the best way to learn and study C++..
Was This Post Helpful? 0
  • +
  • -

#5 HariC  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 11
  • Joined: 16-November 11

Re: how i want to find the max and min value in array?

Posted 23 December 2011 - 01:34 AM

If you are a beginner, just try to learn all the concepts of basic and some in depth concepts of C++ using the following links:

www.exforsys.com
www.cplusplus.com

Learn the language from these websites which are more useful.
Was This Post Helpful? 0
  • +
  • -

#6 sisieablebeable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 14-December 11

Re: how i want to find the max and min value in array?

Posted 24 December 2011 - 09:20 AM

thanks so much haRIC :)
Was This Post Helpful? 0
  • +
  • -

#7 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 665
  • View blog
  • Posts: 2,296
  • Joined: 31-December 10

Re: how i want to find the max and min value in array?

Posted 24 December 2011 - 03:04 PM

Or you could look at the tutorials ON THIS SITE. Don't get me wrong, cplusplus.com is a good C++ reference site.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1