PLEASE HELP!! ID RETURNETD 1 EXIT STATUS

Hi guys, so i am making a small program, and there is an error showing "ID returned 1 exit status. This is the small program:
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
using namespace std;
void add(int a, int b)
{
	int res1;
	res1=a+b;
	cout<<"The answer is: "<<res1;
}
void sub(int a, int b)
{
	int res2;
	res2=a-b;
	cout<<"The answer is: "<<res2;
}
void mult(int a, int b)
{
	int res3;
	res3=a*b;
	cout<<"The answer is: "<<res3;
}
void div(int a, int b)
{
	int res4;
	res4=a/b;
	cout<<"The answer is: "<<res4;
}	
void squ(int a, int b)
{
	int res5;
	int res6;
	res5=a*a;
	cout<<"The square of the first number is: "<<res5;
	res6=b*b;
	cout<<"The square of the second number is: "<<res6;
}
void cub(int a, int b)
{
	int res7;
	int res8;
	res7=a*a*a;
	cout<<"The cube of the first number is: "<<res7;
	res8=b*b*b;
	cout<<"The cube of the second number is: "<<res8;
}
int main(int argc, char** argv) {
	int a;
	int b;
	char op;
	cout<<"Enter the first number:  ";
	cin>>a;
	cout<<"Enter the operator (+,-,*,/,^(square) and #(cube):  ";
	cin>>op;
	cout<<"Enter the second number:  ";
	cin>>b;
	switch (op)
	{
	case '+':
		add(a,b);
		break;
	case 'x':
	case '*':
		mult (a,b);
		break;
	case '-':
		sub(a,b);
		break;
	case '/':
		div(a,b);
		break;
	case '^':
		squ(a,b);
		break;
	case '#':
		cub(a,b);
		break;
	default:"Invalid input";
	}
	return 0;
}



Thanks a lot in advanced!


********************************************************************************
Line 76.
@keskiverto
it should work properly without fixing line 76 but wont be good in output if the default is picked.

@ShehabKKhan reinstall your compiler that is what im doing when i always get that error too. try any codes or just print out hello world it would be same error
closed account (z05DSL3A)
ShehabKKhan, You have a name clash with your function void div(int a, int b) and std::div().


using namespace std; can save you time but can also bite you on the a...
there is an error showing "ID returned 1 exit status.

Did the compiler display any errors? I get errors when I attempt to compile your program.

Line 21: signature conflicts with std::div(). <cstdlib> includes a div() function which has a different return type from yours. The compiler doesn't know which one to use. Even though you don't include <cstdlib>, it may be included by your use of <iostream>. When you use using namespace std; it is not a good idea to name your functions the same as functions in the std:: namespace.

Line 78: If you're running in Windows, when you fall through the switch statement, you will exit the program and the console window will close immediately. See the following thread:
http://www.cplusplus.com/forum/beginner/1988/

@justinelandchoriz
Line 76 is irrelevant if the program won't compile.

A simple compile error is no reason to reinstall the compiler.




@AbstractionAnon
the code is working fine on my compiler. how would you explain it


im not really sure if the OP is using dev c++ .that error is often happens on dev c++.
@justinelandchoriz
As I explained to you in another thread, what header files are included by other header files is implementation specific.

In my implementation and presumably the OP's implementation, <iostream> includes <cstdlib> which is what is causing the naming conflict, however apparently your implementation does not include <cstdlib> from <iostream>.

In the other thread, it was a case of relying on that behavior which is a poor practice. In this case, it problem is more attributable to the use of using namespace std; and having function names that conflict with with function names in the std:: namespace.
There should be usually be additional error messages. For example this short program:
1
2
3
4
5
6
int example(int a, int b);

int main()
{
    example(2, 3);
}

ideone: http://ideone.com/8O33nL
messages:
/home/tpoggq/ccNsepZv.o: In function `main':
prog.cpp:(.text.startup+0x19): undefined reference to `example(int, int)'
collect2: error: ld returned 1 exit status


Note, the useful message is this: undefined reference to `example(int, int)' , it gives more specific information than:collect2: error: ld returned 1 exit status though that is useful too, it translates roughly as "the linker failed".
@AbstractionAnon
I see. I understand. as i remember it was implementation specific. so about from Op's problem you said line 21 has a conflict i think the error should be ambigous
There is only one problem, which takes me to another window. I do not know how to fix it!
and i use devC++
and i use devC++

Try again to compile your program.
After that finishes, right-click on the message panel at the bottom of the screen, and click on "Copy All". That will copy the messages to the clipboard. Finally, paste the result into a post on this forum so we can see the exact text.
yay it worked!! thanks a lot anyway!!!
Topic archived. No new replies allowed.