Please help with this code

I use Cfree 5.0 and this code have 6 error is in the last line and to be honest, i dont know where i go wrong.Please have a look:
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
#include<iostream.h>
using namespace std;
void nhap(int& a);
int LN(int b);
int main()
{
	int a;
	nhap (a);
	LN (a);
	system("paused");
}
void nhap(int& a)
{
	cout<<"nhap so";
	cin>>a;
}
int LN(int b)
{
	for(int n=2,n<b,n++)
	{
		int s=0;
		int g=1;
		for(int i=n,(i<b) && (s<b),++i)
		{
			for (int j=1,j<i,++j)
				if (i%j=0 && i=j)
				{
					s=s+i;
					g=g*i;
				}					
		}
		int t=b-s;
		for(int z=1,t%z!=0,)
		++z;
		if (g%z!=0)
		{
		int k= g*t;
		return k;
		}
	}
}

Error:
[Error] C:\Users\ADMIN\Documents\C-Free\Temp\Untitled1.cpp:19: error: expected initializer before '<' token
[Error] C:\Users\ADMIN\Documents\C-Free\Temp\Untitled1.cpp:41: error: expected primary-expression before '}' token
[Error] C:\Users\ADMIN\Documents\C-Free\Temp\Untitled1.cpp:41: error: expected `;' before '}' token
[Error] C:\Users\ADMIN\Documents\C-Free\Temp\Untitled1.cpp:41: error: expected primary-expression before '}' token
[Error] C:\Users\ADMIN\Documents\C-Free\Temp\Untitled1.cpp:41: error: expected `)' before '}' token
[Error] C:\Users\ADMIN\Documents\C-Free\Temp\Untitled1.cpp:41: error: expected primary-expression before '}' token
[Error] C:\Users\ADMIN\Documents\C-Free\Temp\Untitled1.cpp:41: error: expected `;' before '}' token
Thank.


Last edited on
At line 19, you're using the comma operator. Do you actually know what the comma operator does?

I suspect you meant to use a semicolon instead.

EDIT: You do the same thing in all your for statements.
Last edited on
With the for loops, use the semicolon to depict the end of a statement, not the comma.
Syntax: for(initialization; condition; inc/dec) not for(initialization, condition, inc/dec)

Aceix.
Last edited on
Oh thank you very much.
Well i am still newbie ( just start for a few day) and this one is what i make based soly on algorithm and little knowledge i have in this website plus some old book (well to be honest, most knowlegde i have is more from example than from technical term).
Topic archived. No new replies allowed.