home work help please

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2006
Posts: 2
Reputation: candykane69 is an unknown quantity at this point 
Solved Threads: 0
candykane69 candykane69 is offline Offline
Newbie Poster

home work help please

 
0
  #1
Feb 27th, 2006
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.


#include <iostream>

int recursiveMinimum(int[], int);
int smallest, index;

int main()
{
int x=10;
int array1[10];
smallest=0;
index=0;

return 0;
}


int recursiveMinimum(int array[], int size)
{
if (size<=1) return -1;
if array[index]<smallest
smallest=array[index];
index++;
recursiveMinimum(array, size);
return smallest;
}



this is error i getompiling...
program8.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\project8\program8.cpp(15) : warning C4101: 'array1' : unreferenced local variable
C:\Program Files\Microsoft Visual Studio\MyProjects\project8\program8.cpp(26) : error C2061: syntax error : identifier 'array'
Error executing cl.exe.

project8.exe - 1 error(s), 1 warning(s)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,823
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 748
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Senior Bitch

Re: home work help please

 
0
  #2
Feb 27th, 2006
Those are exceptionally detailed and clear diagnostic messages. What's the problem? 'array1' isn't used and 'array' isn't expected where you put it. Both fixes require no more than a remedial knowledge of C++.
New members chased away this month: 3
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,052
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: home work help please

 
2
  #3
Feb 27th, 2006
candykane, the first is a warning, which means your code is not technically incorrect there. But you have a variable named 'array1', which you aren't using for anything at all! The compiler, being nice and friendly (in a sarcastic sort of way) is telling you this, since maybe it means you made an error, or just have code that could use some cleaning.

The second error is a syntax error (as the compiler informs you). 'if' branches do not use that sort of syntax in C++.
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2
Reputation: candykane69 is an unknown quantity at this point 
Solved Threads: 0
candykane69 candykane69 is offline Offline
Newbie Poster

Re: home work help please

 
0
  #4
Feb 27th, 2006
thank you
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC