what is the wrong in this code !

the compiler does not enter into inter for !!

who can tell me why ?



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


#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace std;




int fun(int x,int y);

int main()

{
	int a,b;
	cin>>a>>b;

	cout<<odai(a,b);
	cout<<endl;


	cout<<a<<b;
	cout<<endl;

	for(a;a<3;a--)
	{
		cout<<rand();
	}
	system("pause");


	return 0;

}

int fun(int x,int y)

{

	return x*y;
}
because a does not equal anything in the for loop. Try a = 0 because your saying if a<3 but a hasnt been assigned a value yet.
Last edited on
no it's the same mistake , logical error :(
cout<<odai(a,b);
Does this even compile?
yea it's right !!
Well, assuming odai is a function or macro, what is it doing?
nothing , but your number a , b and see the result .

You may also want to study your for loop I get the following warning:
main.cpp||In function ‘int main()’:|
main.cpp|25|warning: statement has no effect [-Wunused-value]|


The condition clause seems to be incorrect.

Last edited on
how is that !! mmmm can you tell me were is the wrong ?
for(a;a<3;a--)
So say you enter 2 for a, when will this loop ever end?

But the actual problem noted by the compiler is the first part, the initialization section. You either need to initialize the variable or leave that section blank.

my friend i already do it and put an initialize but the same mistake !! and i enter a 10 and still there a mistake !!


i don't know why !!
Post your corrected code.
no thx i know what is the wrong now ^_^ like you say i put a wrong number !!
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
#include<iostream>
#include<cstdlib>
#include<ctime>

using namespace std;

int fun(int x,int y); // declares function fun

int main()

{
	int a,b;
	cin>>a>>b;

	cout<<odai(a,b); // uses undefined function. Maybe you meant fun() function to be called
	cout<<endl;

	cout<<a<<b; // Next applies above too
	cout<<endl; // These 2 lines can be written: cout << a << b << endl;

	for(a;a<3;a--)
	{
		cout<<rand(); // If you want to use rand() as "real" randomizer, give it a seed
	}
	system("pause");

	return 0;
}

int fun(int x,int y)
{
	return x*y;
}
Topic archived. No new replies allowed.