I just wrote this code to implement a basic function but I am getting weird compile errors. I am using Ubuntu and compiling on bash via g++.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
void array_printer(int arr[], int size,int arr1[])
{
int i,j,k;
if (arr[size] == 0)
{ cout <<"Impossible"<< endl;}
else
for (i=0, i<size, i++)
{
cout << arr1[i]" x "arr[i];
}
}
int main()
{
int n,i,k,j,l;
int arr[n];
int arr1[n];
cin >> n;
if (!cin.fail())
{
for (i=0, i < n+1, i++)
{
cin >> j;
arr[n];
arr[i] = j;
}
l = arr[n];
for (k=0, k < n+1, k++)
{
arr1[k] = l/arr[k];
l = l % arr[k];
}
}
array_printer(arr, n, arr1);
return 0;
}
|
The compile error is the following:
a2q2.cc: In function ‘void array_printer(int*, int, int*)’:
a2q2.cc:14: error: expected ‘;’ before ‘)’ token
a2q2.cc:19: error: expected primary-expression before ‘}’ token
a2q2.cc:19: error: expected ‘;’ before ‘}’ token
a2q2.cc:19: error: expected primary-expression before ‘}’ token
a2q2.cc:19: error: expected ‘)’ before ‘}’ token
a2q2.cc:19: error: expected primary-expression before ‘}’ token
a2q2.cc:19: error: expected ‘;’ before ‘}’ token
a2q2.cc: In function ‘int main()’:
a2q2.cc:33: error: expected ‘;’ before ‘)’ token
a2q2.cc:42: error: expected primary-expression before ‘for’
a2q2.cc:42: error: expected ‘)’ before ‘for’
a2q2.cc:42: error: expected ‘;’ before ‘)’ token
a2q2.cc:47: error: expected primary-expression before ‘}’ token
a2q2.cc:47: error: expected ‘;’ before ‘}’ token
a2q2.cc:47: error: expected primary-expression before ‘}’ token
a2q2.cc:47: error: expected ‘)’ before ‘}’ token
a2q2.cc:47: error: expected primary-expression before ‘}’ token
a2q2.cc:47: error: expected ‘;’ before ‘}’ token
Can anyone help me out to tell me where my syntax is wrong? thanks a lot