|
-
April 13th, 2012, 07:08 PM
#1
[RESOLVED] Help writing code.
value Write a function, contains, that accepts an array of integers, the number of elements in the array and an integer value, and returns a boolean value indicating whether the value appears as an element of the array (arrays as parameters, basic search algorithm)
bool contains(int a[], int n, int val)
{
for(int i = 0; i < n; i++)
{
if(a[i] == val)
{
return = true;
}
}
}
what am i doing wrong..
-
April 14th, 2012, 07:55 AM
#2
Re: [RESOLVED] Help writing code.
 Originally Posted by mejiac3
what am i doing wrong..
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
April 14th, 2012, 10:08 AM
#3
Re: [RESOLVED] Help writing code.
You also miss a return false; at the end of the function but your compiler has probably already told you that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|