Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Finding Smallest int in an int array

Posted on 2003-03-01
9
Medium Priority
?
198 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

581 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