The programming challenge I am trying to solve is states as: write a function that accepts three arguments: an array, the size of the array, and a number n. Assume that the array contains integers. The function should display all of the numbers in the array that are greater than the number n.
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
void largerThanN(int a[], int size, int n);
int main()
{
int size = 3,
n = 1,
arr[3] = { 0,5,6 };
largerThanN(arr, size, n);
}
void largerThanN(int a[], int size, int n)
{
for (int i = 0; i < size; i++)
{
if (a[i] > n)
{
cout << a[size] << " is greater than n " << endl;
}
}
}
This is what I have convoluted so far but I don't know if this is even remotely close to solving the challenge, maybe some direction from pro C++ devs would help out.
EDIT: I've figured it out with some help from you guys in the comments, thank you guys for helping a newbie out. it means a lot.