Recursive
2012-06-03 00:03:37
Code is below
Problem: Whenever I click compile, it gives an error. Now I have kinda life cpp and moved on to pascal so my cpp might be a bit rusty but someone please help with this.
Don't worry about the logic I used in the coding, I just want to know if the format is right. If you just can't stand the logic then go ahead and suggest something.
Problem: Whenever I click compile, it gives an error. Now I have kinda life cpp and moved on to pascal so my cpp might be a bit rusty but someone please help with this.
Don't worry about the logic I used in the coding, I just want to know if the format is right. If you just can't stand the logic then go ahead and suggest something.
#include <iostream>
using namespace std;
int smallest(int array[], int size)
{
int a;
if (size ==1)
{
return array[0];
}
else
{
for (int i = 0; i < size; i++)
{
If (array[i] < array[i+1])
{
a = array[i];
}
else
{
a = array[i+1];
}
}
If (i = 10) then
{
return a;
}
}
}
int main()
{
int array[10]={-1, 5, -23, 90, 4, 5, 6, -2, -100,9 };
cout<<smallest(array, 10);
return 0;
}