?
Solved

Finding Smallest int in an int array

Posted on 2003-03-01
9
Medium Priority
?
197 Views
Last Modified: 2010-04-01
how can i iterate through an int array of 256 int's and find the smallest number and save it to a var.?

I know it sounds simple (and probably is) but i cant get it, my teacher says its less than 10 lines of code
0
Comment
Question by:gregrego
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 3

Expert Comment

by:loki982
ID: 8050844
i am not in the habit of doing homework for those who don't even try...
post some code

-loki
0
 

Author Comment

by:gregrego
ID: 8050864
well, its a multifile program and its hard because this is the only function in this cpp.

And yes i have been trying for hours, if you dont know how to then dont post, you didnt have to be an ass.
0
 

Author Comment

by:gregrego
ID: 8050889
k nm i got it i was just missing an if statement!! FUCKKK

int Short(int const * const piArray)
{
int iShort = piArray[0];
for(int iCount,iCount<256,iCount++)
{
if(piArray[iCount])
{
if(piArray[iCount] < iShort)
iShort = piArray[iCount];
}}}
return iShort;
}

so next person to ask for points gets em for free :P
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Accepted Solution

by:
PlanetCpp earned 200 total points
ID: 8051023
lol hey i'll take em
0
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8051024
i feel bad lol you can ask the moderators to delete the post and reimburse the points
0
 

Expert Comment

by:Grass_Hopper
ID: 8051026
{
    int smallest;

    smallest = Array[0];
    for(int i = 0; i < 256; i++)
    {
        if(Array[i] < smallest)
            smallest = Array[i];
    }
    return smallest;
}

int FreePoints = mine;  :-)
0
 

Expert Comment

by:Grass_Hopper
ID: 8051029
{
    int smallest;

    smallest = Array[0];
    for(int i = 0; i < 256; i++)
    {
        if(Array[i] < smallest)
            smallest = Array[i];
    }
    return smallest;
}

int FreePoints = mine;  :-)
0
 

Expert Comment

by:Grass_Hopper
ID: 8051033
oops lol
0
 

Author Comment

by:gregrego
ID: 8051945
lol thats ok its only 50 i got so many points left lol
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question