944,086 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2612
  • C++ RSS
Nov 17th, 2004
0

Compiler error

Expand Post »
Greetings:

I am taking my first C++ class and am a little stuck. I keep receiving three compiler errors, but I can't seem to figure them out. Can someone please point me in the right direction.

The assignment is:

Write a C++ program having a recursive function recursiveMinimum that takes an integer array and the array size as arguments and returns the smallest element of the array. The function should stop processing and return when it receives an array of 1 element.

I am attaching my .cpp file.

Thanks to anyone that can assist me.

By the way, God bless all you gurus. If this is a beginner's class, I hate to see the advanced classes.
Attached Files
File Type: cpp main.cpp (415 Bytes, 39 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thiodre26 is offline Offline
2 posts
since Sep 2004
Nov 17th, 2004
0

Re: Compiler error

>I am attaching my .cpp file.
Don't do this. Post the code. If the code is too long, post relevant pieces. Your attachment is very small, so the code is short enough to post.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Nov 17th, 2004
0

Re: Compiler error

You were doing fine up until this routine:
C++ Syntax (Toggle Plain Text)
  1. int recursiveMinimum(int[] array, int size)
  2. {
  3. if size<=1 return -1;
  4. if array[index]<smallest
  5. smallest=array[index];
  6. index++;
  7. recursiveMinimum(array, size);
  8. return smallest;
  9. }

1) should be int array[] not int[] array
2) if statements always have their argument in parens, like "if (size <=1) return -1;"

Next time, please post the exact error message too so we don't have to play compiler for you. :-)
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: SHA1-One-Way Hash
Next Thread in C++ Forum Timeline: beginner





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC