Id returned 1 exit status

Creating a program for fun, making it to show me my homework for the semester and such. But I have a few problems. I'm getting the "Id returned 1 exit status" error when I compile this. And another thing, I dont know how to make it return to main like its a main menu.

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
#include<iostream>
#include<iomanip>
#include<stdlib.h>
using namespace std;
void math(int answer, int day, int month);
void ComSci(int answer, int day, int month);
void Chemistry(int answer, int day, int month);
void Music(int answer, int day, int month);
int main()
{
	int answer;
	int day;
	int month;
	cout << "What is the month (in numbers)?  ";
	cin >> month;
	cout << "What is the day of this month?   ";
	cin >> day;
	cout << setw(5) << "HOMEWORK" << setw(5) << endl;
	cout << "_____________________________" << endl;
	cout << "Press 1 for math \nPress 2 for C++  \nPress 3 for Chemistry  \nPress 4 for Music" << endl;
	cin >> answer;
	
	math(answer,day,month);
	
	return 0;
}
void Math(int answer, int day, int month)
{
	int q;
	if(answer == 1)
	{
		system("cls");
		if(month == 11 && day <= 19)
		{
			cout << "Homework: " << endl;
			cout << "11/19:      " << "Hw 10.4 \nLesson and hw 10.5 \nChapter 10 review \nQuiz 10.3-10.5 \nLesson 11.1" << endl;
			cout << "11/26:      " << "Lesson and Hw 11.2" << endl;
			cout << "12/03:      " << "Lesson and Hw 11.3 \nQuiz 11.2-11.3 \nLesson and Hw 11.4" << endl;
			cout << "12/10:      " << "Hw 11.6 \nLesson and Hw 11.7 \nChapter 11 Review \nBonus Quiz" << endl;    	
		}
		else if(month == 11 && (day <= 26 && day > 19))
		{
			cout << "Homework: " << endl;
			cout << "11/26:      " << "Lesson and Hw 11.2" << endl;
			cout << "12/03:      " << "Lesson and Hw 11.3 \nQuiz 11.2-11.3 \nLesson and Hw 11.4" << endl;
			cout << "12/10:      " << "Hw 11.6 \nLesson and Hw 11.7 \nChapter 11 Review \nBonus Quiz" << endl; 		
		}
		else if(month == 12 && day <= 3)
		{
			cout << "Homework: " << endl;
		cout << "12/03:      " << "Lesson and Hw 11.3 \nQuiz 11.2-11.3 \nLesson and Hw 11.4" << endl;
		cout << "12/10:      " << "Hw 11.6 \nLesson and Hw 11.7 \nChapter 11 Review \nBonus Quiz" << endl;
		}
		else
		{
			cout << "Homework: " << endl;
			cout << "12/10:      " << "Hw 11.6 \nLesson and Hw 11.7 \nChapter 11 Review \nBonus Quiz" << endl;
		}
	  
	}

}
Last edited on
First, it's ld (LD), not Id. It means you have linker errors.

C++ is case sensitive.

This is your function declaration:
void math(int answer, int day, int month);

This is your function definition:
1
2
3
4
void Math(int answer, int day, int month)
{
    // ...
}

Last edited on
Wow, I feel so stupid.
Thank you!
And do you know how I would be able to re-run it through so it can work like a main menu?
Hello wubbits,

When I compiled the program this is what I received:

Severity	Code	Description	Project	File	Line	Suppression State
Warning	C4101	'q': unreferenced local variable	Id returned 1 exit status EP	e:\vs projects\id returned 1 exit status ep\id returned 1 exit status ep\original code.cpp	29	
Error	LNK2019	unresolved external symbol "void __cdecl math(int,int,int)" (?math@@YAXHHH@Z) referenced in function _main	Id returned 1 exit status EP	E:\VS Projects\Id returned 1 exit status EP\Id returned 1 exit status EP\Original Code.obj	1	
Error	LNK1120	1 unresolved externals	Id returned 1 exit status EP	E:\VS Projects\Id returned 1 exit status EP\Debug\Id returned 1 exit status EP.exe	1	

The warning means that you defined "q" in the function and never used it.

Not that the error message is clear, but it refers to the prototype,function call and the function definition. All three have to match. Check your spelling. Case does make a difference.

I am not sure what this means "Id returned 1 exit status". I would guess that since the compile has errors this is just telling you there is a problem. Once you correct the errors everything is fine.

When it compiles the program does work.

Hope that helps,

Andy
Hello Andy,

ld is the widows linker. An exit status of non zero means that it failed. So the compilation was successful, but the link failed. (The error message is obviously from the linker.)

Hope that helps,

tpb
Topic archived. No new replies allowed.