| | |
home work help please
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2006
Posts: 2
Reputation:
Solved Threads: 0
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)
#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)
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++.
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.
![]() |
Similar Threads
- Recursive Fibonacci (C)
- Internet Connection Sharing won't work! (Windows NT / 2000 / XP)
- how can I copy asp.net project from one system and work on it in a different system (ASP.NET)
- c home work (C)
- IE problems - about: blank setting self as home page (Viruses, Spyware and other Nasties)
- help me in this home work please (C++)
- Hi everyone (Geeks' Lounge)
- set me some home work plz (C++)
Other Threads in the C++ Forum
- Previous Thread: assignment operator for a 3d array
- Next Thread: C++ homework Problem
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






