C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 9th, 2003, 02:07 AM
magdaolsen magdaolsen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: New York
Posts: 8 magdaolsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrays + functions

Last one for the evening:
Trying to find a maximum value in an aray, by passing the array to a function and returning the value:
PHP Code:
 double MaxGrade (int NumStudentsdouble FinalGrade[]);
double MinGrade (int NumStudentsdouble FinalGrade[]);
const 
SIZE=35;
void main(void)
{
//Assume array FinalGrade[SIZE] is filled with values

double FinalGrade[SIZE];
cout <<"The maximum grade is:" << MaxGrade (NumStudentsFinalGrade) << endl;
cout <<"The minimum grade is:" << MinGrade (NumStudentsFinalGrade) << endl;
}
double MaxGrade (int NumStudentsdouble FinalGrade[])
{
    
//Declare variables
    
double MaxGrade(0.0);
    
int i(0);

    
MaxGrade FinalGrade[i];

    for (
i=0NumStudentsi++)
    
        if 
FinalGrade[i] > MaxGrade
            MaxGrade 
FinalGrade[i];

    return 
MaxGrade;

}

double MinGrade (int NumStudentsdouble FinalGrade[])
{
//Declare variables
    
double MinGrade(0.0);
    
int i(0);

    
MinGrade FinalGrade[i];

    for (
i=0NumStudentsi++)
        if 
FinalGrade[i] < MinGrade
            MinGrade 
FinalGrade[i];

    return 
MinGrade;




Compiler gives me a syntax error: Indentifier "FinalGrade" in both functions Min & Max Grade on the if statement line.
Thanks for any pointers!

Reply With Quote
  #2  
Old April 9th, 2003, 09:54 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 3,799 dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Month 9 h 55 m 28 sec
Reputation Power: 437
Where are the parentheses around the condition of the if-statements?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Arrays + functions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway