C++

Hi I have created a program but i'm stuck in one thing that if press 1 then the new windows is open and the existing one is close and also how to return to main menu. how to open every program in new window with exiting the first window...
\\ Here is my program
#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int main(){
int a;
a = 1, 2;
{
cout << "Press 1 for selection program:\n";
cout << "Press 2 for looping:\n";
cout << "Press 3 to exit program:\n";
cout << "Enter your choice:\n";
}

cin >> a;
{
if (a == 1)
{
cout << "Press 1 Pass or Fail\n";
cout << "Press 2 Even or Odd\n";
cout << "Press 3 Leap year\n";
cout << "Press 4 Salary or Grade\n";
}
}
if (a == 1)
{
int marks;
cout << "Enter your Marks\n";
cin >> marks;
if (marks >= 60)
{
cout << "Congratulations you have passed\n";
}
else
{
cout << "You're failed\n";
}
}
if (a == 2)
{
int integer;
cout << "Please enter an integer"
<< endl;
cin >> integer;
if (integer % 2 == 0)
cout << integer << " is even "
<< endl;
else
cout << integer << " is odd "
<< endl;
return 0;
}
if (a == 3)
{
int year;

cout << "\n Enter the year = ";
cin >> year;

if (year % 4 == 0 || year % 400 == 0 || year % 100 == 0)
cout << "this is a leap year" << endl;

else
cout << "this is not a leap year" << endl;
if (a == 4)
{
float salary, bonus;
int grade;
cout << "Enter your salary:\n";
cin >> salary;
cout << "Enter your grade:\n";
cin >> grade;
if (grade > 50)
bonus = salary * 70 / 100;
else
bonus = salary * 35 / 100;
salary = salary + bonus;
cout << "Your total salary is Rs.\n";
cout << salary;
}
}
if (a == 2)
{
cout << "Press 1 for Table program\n";
cout << "Press 2 Factorial\n";
cout << "Press 3 Sentinel loops\n";
cout << "Press 4 Main menu\n";
}
if (a == 1)
{
int n;
cout << "Enter an integer: ";
cin >> n;
for (int i = 1; i <= 10; ++i) {
cout << n << " * " << i << " = " << n*i << endl;
n = n + 1;
}
}
if (a == 2)
{
long int n, c, f;
c = 1;
f = 1;
cout << "Enter a number :\n";
cin >> n;
while (c <= n)
{
f = f*c;
c = c + 1;
}
cout << "Factorial of\n" << n << "is" << f << endl;
}
if (a == 3)
{
int n;
n = 1;
while (n != -2)
{
cout << "Hello Pakistan!!!\n";
cout << "Do you want to continue:\n";
cin >> n;
}
}
if (a == 4)
{
cout << "Here you go to main window";
}
system("pause");
}
Use code tags please
Your indentation is killing.

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <iostream>
#include <stdio.h>	//dont mix cpp code with C libs
#include <cstdlib>

using namespace std;

int main()
{
	int a;
	a = 1, 2;		//what does this mean?
	//{					//why is this brace here ...
	cout << "Press 1 for selection program:\n";
	cout << "Press 2 for looping:\n";
	cout << "Press 3 to exit program:\n";
	cout << "Enter your choice:\n";
	//}					//and here...

	cin >> a;
	//{	// DO YOU REALLY KNOW WHAT "curly braces" ARE USED FOR???
	
	if (a == 1)
	{
		cout << "Press 1 Pass or Fail\n";
		cout << "Press 2 Even or Odd\n";
		cout << "Press 3 Leap year\n";
		cout << "Press 4 Salary or Grade\n";
	//}
	//You have to get the input.
	//reason why you always get "you failded".
		cin>>a;
		//}
		if (a == 1)
		{
			int marks;
			cout << "Enter your Marks\n";
			cin >> marks;
			if (marks >= 60)
			{
				cout << "Congratulations you have passed\n";
			}
			else
			{
				cout << "You're failed\n";
			}
		}
		if (a == 2)
		{
			int integer;
			cout << "Please enter an integer"<< endl;
			cin >> integer;
			if (integer % 2 == 0)
				cout << integer << " is even "<< endl;
			else
				cout << integer << " is odd "<< endl;
			//DO YOU REALLY WANT TO QUIT THE PROGRAM HERE??
			return 0;
		}
		if (a == 3)
		{
			int year;

			cout << "\n Enter the year = ";
			cin >> year;

			if (year % 4 == 0 || year % 400 == 0 || year % 100 == 0)
			cout << "this is a leap year" << endl;

			else
				cout << "this is not a leap year" << endl;
		}
		if (a == 4)
		{
			float salary, bonus;
			int grade;
			cout << "Enter your salary:\n";
			cin >> salary;
			cout << "Enter your grade:\n";
			cin >> grade;
			if (grade > 50)
				bonus = salary * 70 / 100;
			else
				bonus = salary * 35 / 100;
			salary = salary + bonus;
			cout << "Your total salary is Rs.\n";
			cout << salary;
		}
	}
	if (a == 2)
	{
		cout << "Press 1 for Table program\n";
		cout << "Press 2 Factorial\n";
		cout << "Press 3 Sentinel loops\n";
		cout << "Press 4 Main menu\n";
	
		//get input
		cin>>a;
		if (a == 1)
		{
			int n;
			cout << "Enter an integer: ";
			cin >> n;
			for (int i = 1; i <= 10; ++i) {
			cout << n << " * " << i << " = " << n*i << endl;
			n = n + 1;
			}
		}
		if (a == 2)
		{
			long int n, c, f;
			c = 1;
			f = 1;
			cout << "Enter a number :\n";
			cin >> n;
			while (c <= n)
			{
				f = f*c;
				c = c + 1;
			}
			cout << "Factorial of\n" << n << "is" << f << endl;
		}
		if (a == 3)
		{
			int n;
			n = 1;
			while (n != -2)
			{
				cout << "Hello Pakistan!!!\n";
				cout << "Do you want to continue:\n";
				cin >> n;
			}
		}
		if (a == 4)
		{
			cout << "Here you go to main window";
		}
	}
	if(a == 3)
	{
		cout<<"You choosed to quit"<<endl;
		cout<<"Bye..."<<endl<<endl;
	}
	system("pause");
	return 0;
}


the new windows is open and the existing one is close and also how to return to main menu

What windows are you talking about??
Topic archived. No new replies allowed.