Very new to programming and was asked to find errors in a program code as tutorial. While trying to fix it, I kept getting the line " argument of type 'int' incompatible with parameter of type 'int' " for the line labeled passing individual elements. Haven't learn about pointers, and don't really understand how functions work either, so there might be errors elsewhere.
#include <iostream>
using namespace std;
void functionA ( int num[] ) ;
void functionB ( int newnumbers[] ) ;
void functionC ( int newnumbers[] ) ;
void main ()
{
int numbers[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } ;
int i;
for ( i=0; i<10; i++ )
functionA ( numbers[i] ) ; // passing individual elements
cout << "\n\n" ;
functionB ( numbers ) ; // passing the whole array
functionC ( numbers ) ; // passing the whole array
cout << "\n\n" ;
}
void functionA ( int num[] )
{
cout << num << " " ;
}
void functionB ( int newnumbers[] )
{
for ( int i=0; i<10; i++ )
newnumbers[i] = newnumbers[i] * 5 ;
}
void functionC ( int newnumbers[] )
{
for ( int i=0; i<10; i++ )
cout << newnumbers[i] << " " ;
}