Exiting the program borland turbo c++

need to exit the program when wrong inputs how to do it??


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.h>
#include<conio.h>
#include<cstring.h>
int main()
{
char c,a,s,d,e;
cout<<" Enter Password to Unlock The Program";

while(c!='s')
{
cin>>c;
switch(c)
{
case 's':
cout<<"Carry On\n s";
break;
default:
cout<<"\nTry Again";
break;
}
}
getch();
while(a!='h')
{
cin>>a;
switch(a)
{
case 'h':
cout<<"Carry On\n sh";
break;
default:
cout<<"\nTry Again\n s";
break;
}
}
getch();
while(s!='a')
{
cin>>s;
switch(s)
{
case 'a':
cout<<"Carry On\n sha";
break;
default:
cout<<"\nTry Again\n sh";
break;
}
}
getch();
while(d!='n')
{
cin>>d;
switch(d)
{
case 'n':
cout<<"Carry On\n shan";
break;
default:
cout<<"\nTry Again\n sha";
break;
}
}
getch();
while(e!='u')
{
cin>>e;
switch(e)
{
case 'u':
cout<<"Great Press Y And Enter";
break;
default:
cout<<"\nWrong Password Exiting.....";
break;
}
}
getch();
}
Last edited on
closed account (Dy7SLyTq)
just do return -1; it could be any int though
there is also:
exit(int)
abort()
and one i just learned about: terminate()
The first and third lines should be #include<iostream> and #include <cstring> . Drop the .h.

<conio.h> is a generally-outdated header and I strongly advise against using it.

Of DTSCode's advice, using return 1; is by far the best option. The others don't play nicely with C++ methodologies.

-Albatross
well i am using borland turbo c++ tried to use visual c++ but did not understood anything how to do all those stuff so i wud work out on what u friends want me to do
sorry if i sound rude

Edit sorry not working with any of the above tricks
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
// Physics theorems
#include<iostream.h>
#include<conio.h>
#include<math.h>
#define pi   3.14159265
#define RPD  (pi/180)
#define DPR  (180/pi)
int main(void)
{

char c,a,s,d,e;
cout<<" Enter Password to Unlock The Program";

while(c!='$')
{
cin>>c;
switch(c)
{
case '$':
cout<<"Initializing DataBases.......";
break;
default:
cout<<"\nTry Again";
break;
}
}
getch();
while(a!='#')
{
cin>>a;
switch(a)
{
case '#':
cout<<"\nValidating assword......";
break;
default:
cout<<"\nTry Again";
break;
}
}
getch();
while(s!='@')
{
cin>>s;
switch(s)
{
case '@':
cout<<"\nChecking Registry for Passkey..............";
break;
default:
cout<<"\nTry Again";
break;
}
}
getch();
while(d!='&')
{
cin>>d;
switch(d)
{
case '&':
cout<<"Logging In............";
break;
default:
cout<<"\nTry Again";
break;
}
}
getch();
while(e!='u')
{
cin>>e;
switch(e)
{
case 'u':
cout<<"\nLogged In Succesfully As KumarShanu";
break;
default:
cout<<"\nWrong Password Exiting.....";
break;

[big]
What should i place here?? to terminate the program??
[/big]
}
Last edited on
indentation
<nolyc> indentation is optional whitespace. see also: !vowel
vowel
<nolyc> vwls r bt s sfl s whtspc, spclly n vrbl nms. s ls: !ndnttn
Topic archived. No new replies allowed.