Press any key to continue

Hi guys! Could you please help me? how i am going to search after the visuals? It must be looks like:

1.Visual
2.(in a certain position)Press any key to continue...
3.Enter the atomic number:
4.output

204,205,206 is not working.

i combined the function and visuals that i make. But it gives me an error after i combined and try to fixed it the message are:

Compiling COMBINE.CPP:
Warning COMBINE.CPP 202: Function should return a value
Warning COMBINE.CPP 204: Style of function definition is now obsolete
error COMBINE.CPP 204: ) expected
Warning COMBINE.CPP 205: tyle of function definition is now obsolete
error COMBINE.CPP 205: ) expected
error COMBINE.CPP 207: ) unxexpected
error COMBINE.CPP 211: Body has already been defined for function 'main()

please help... :(

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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<dos.h>
#include<fstream.h>
#include<graphics.h>
#define r rectangle
#define a outtextxy
#define b settextstyle
#define c setfillstyle
#define d floodfill

int main()
{
 int gm,gd;
 gd=VGA;
 gm=VGAHI;
 initgraph(&gd,&gm,"");

 // 1st Line


 /*HYDROGEN (H)*/

 b(2,0,2);a(32,9,"1");b(2,0,5);a(32,17,"H");b(2,0,2);a(32,33,"Hydrogen");

 c(1,4);
 r(30,8,65,48);
 d(31,16,15);

/*LITHIUM (Li)*/

 b(2,0,2);a(32,49,"3");b(2,0,5);a(32,57,"Li");b(2,0,2);a(32,73,"Lithium");

 c(1,5);
 r(30,48,65,89);
 d(31,49,15);

 /* SODIUM (Na) */

 b(2,0,2);a(32,90,"11");b(2,0,5);a(32,98,"Na");b(2,0,2);a(32,114,"Sodium");

 c(1,5);
 r(30,89,65,129);
 d(31,90,15);

 /* Potassium (K) */

 b(2,0,2);a(32,130,"19");b(2,0,5);a(32,138,"K");b(2,0,2);a(31,154,"POTASSIUM");

 c(1,5);
 r(30,129,65,170);
 d(31,130,15);

/* Rubdium (Rb) */

 b(2,0,2);a(32,171,"37");b(2,0,5);a(32,179,"Rb");b(2,0,2);a(32,195,"Rubdium");

 c(1,5);
 r(30,170,65,211);
 d(33,179,15);

 /* Cesium (Cs) */

 b(2,0,2);a(32,212,"55");b(2,0,5);a(32,220,"Cs");b   (2,0,2);a(32,236,"Cesium");

 c(1,5);
 r(30,211,65,252);
 d(31,221,15);

 /* Francium (Fr) */

 b(2,0,2);a(32,253,"87");b(2,0,5);a(32,261,"Fr");b (2,0,2);a(32,277,"Francium");

 c(1,5);
 r(30,252,65,293);
 d(31,253,15);

 // 2nd Line

 /*BERYLLIUM (Be)*/

 b(2,0,2);a(67,49,"4");b(2,0,5);a(67,57,"Be");b(2,0,2);a(67,73,"Beryllium");

 c(1,2);
 r(65,48,100,89);
 d(66,49,15);

 /* Magnesium (Mg) */

 b(2,0,2);a(67,90,"12");b(2,0,5);a(67,98,"Mg");b(2,0,2);a(67,114,"Magnesium");

 c(1,2);
 r(65,89,100,129);
 d(66,90,15);

 /* Calcium (Ca) */

 b(2,0,2);a(67,130,"20");b(2,0,5);a(67,138,"Ca");b(2,0,2);a(67,154,"Calcium");

 c(1,2);
 r(65,129,100,170);
 d(66,139,15);

 /* Strontium (Sr) */

 b(2,0,2);a(67,171,"38");b(2,0,5);a(67,179,"Sr");b(2,0,2);a(67,195,"Stronium");

 c(1,2);
 r(65,170,100,211);
 d(66,171,15);

 /* Barium (Ba) */

 b(2,0,2);a(67,212,"56");b(2,0,5);a(67,220,"Ba");b(2,0,2);a(67,236,"Barium");

 c(1,2);
 r(65,211,100,252);
 d(66,212,15);

/* Radium (Ra) */

 b(2,0,2);a(67,253,"88");b(2,0,5);a(67,261,"Ra");b(2,0,2);a(67,277,"Radium");

 c(1,2);
 r(65,252,100,293);
 d(66,253,15);

 // 3rd Line

  /* SCANDIUM (Sc) */

 b(2,0,2);a(102,130,"21");b(2,0,5);a(102,138,"Sc");b(2,0,2);a(102,154,"Scandium");

 c(1,6);
 r(100,129,135,170);
 d(101,130,15);

/* Ythrium (Y) */

 b(2,0,2);a(102,171,"39");b(2,0,5);a(102,179,"Y");b(2,0,2);a(102,195,"Ythrium");

 c(1,6);
 r(100,170,135,211);
 d(101,171,15);

 // 4th Line


 /* Titanium (Ti) */

 b(2,0,2);a(137,130,"22");b(2,0,5);a(137,138,"Ti");b(2,0,2);a(137,154,"Titanium");

 c(1,6);
 r(135,129,170,170);
 d(136,130,15);


 /* Zirconium (Zr) */

 b(2,0,2);a(137,171,"40");b(2,0,5);a(137,179,"Zr");b(2,0,2);a(137,195,"Zirconium");

 c(1,6);
 r(135,170,170,211);
 d(136,171,15);


 /* Hafnium (Hf) */

 b(2,0,2);a(137,212,"72");b(2,0,5);a(137,220,"Hf");b(2,0,2);a(137,236,"Hafnium");

 c(1,6);
 r(135,211,170,252);
 d(136,212,15);

 /* Rutherfordium (Rf) */

 b(2,0,2);a(137,253,"104");b(2,0,5);a(137,261,"Rf");b(2,0,2);a(137,277,"Rutherfor");b(2,0,2);a(137,285,"dium");

 c(1,6);
 r(135,252,170,293);
 d(136,253,15);
 //5th Line

 /* Vanadium (V) */

 b(2,0,2);a(172,130,"23");b(2,0,5);a(172,138,"V");b(2,0,2);a(172,154,"Vandium");

 c(1,6);
 r(170,129,205,170);
 d(171,130,15);


 getch();

 closegraph();

 
 }

 gotoxy(x,24);
 cputs("Press Any Key To Continue....");
 getch();
 }

int main()

{
 clrscr();
 int number;

 printf("Enter the atomic number of element(s):");
 scanf("%d",&number);

 switch (number)
   {
   case 1:
   gotoxy(21,10);
   cout<<"Atomic Number : 1";
   gotoxy(21,11);
   cout<<"symbol : H";
   gotoxy(21,12);
   cout<<"Element Name : Hydrogen";
   break;

   case 3:
   gotoxy(21,10);
   cout<<"Atomic Number : 3";
   gotoxy(21,11);
   cout<<"Symbol : Li";
   gotoxy(21,12);
   cout<<"Element Name : Lithium";
   break;

   case 11:
   gotoxy(21,10);
   cout<<"Atomic Number : 11";
   gotoxy(21,11);
   cout<<"Symbol : Na";
   gotoxy(21,12);
   cout<<"Element Name : Sodium";
   break;

   case 19:
   gotoxy(21,10);
   cout<<"Atomic number : 19";
   gotoxy(21,11);
   cout<<"Symbol : K";
   gotoxy(21,12);
   cout<<"Element Name : Potassium";
   break;

   case 37:
   gotoxy(21,10);
   cout<<"Atomic Number : 37";
   gotoxy(21,11);
   cout<<"Symbol : Rb";
   gotoxy(21,12);
   cout<<"Element Name: Rubdium";
   break;

   case 55:
   gotoxy(21,10);
   cout<<"Atomic Number : 55";
   gotoxy(21,11);
   cout<<"Symbol : Cs";
   gotoxy(21,12);
   cout<<"Element Name : Cesium";
   break;

   case 87:
   gotoxy(21,10);
   cout<<"Atomic Number : 87";
   gotoxy(21,11);
   cout<<"Symbol : Fr";
   gotoxy(21,12);
   cout<<"Element Name : Francium";
   break;
   default:printf("eng! wrong. :(");

   }
   getch();

   return 0;
  }

Last edited on
1
2
3
4
5
#define r rectangle
#define a outtextxy
#define b settextstyle
#define c setfillstyle
#define d floodfill 

This is crazy.


You've got more than one main function in the same program. That's illegal.
Last edited on
i'll already fix and it's working now. Yea, i thought it works if i do that hehe. Btw, do you know sir @repeater, how to return into search bar which is in the 215? like, after i search i could back to search again or press a certain key to exit. Do you know how sir?
You're asking "what is a loop?" http://www.cplusplus.com/doc/tutorial/control/

I recommend the while loop for your case.

1
2
3
4
5
6
7
8
9
10
while (true)
{

   // everything that should happen repeatedly here

  if ( time_to_break_out_of_loop)
  {
    break;
  }
}


I tried the for loop, while loop and do while loop. But it doesn't work. Well, tbh, it's really hard for me to understand the looping. I tried that too the "while(true)" and it doesn't work in turbo c++. What should i do?
Show us the code you tried.

in turbo c++. What should i do?
Not related to this question specifically, but stop using Turbo C++. It's from THIRTY years ago. It doesn't support correct C++. It makes 16 bit programs. It's a terrible choice in this world of numerous free, modern and correct C++ compilers and IDEs.
Last edited on
it only gives me an error message and it says "do statement must have while". I'd like to go back it from the start (visual) but i don't know how to. I can't fix it.

the concept must be :

1.visual
2.search
3. ask (13)
4.visual again
5. search again.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
char p;

 do
 { 
  //visual
  

  //enter an atomic number

  // switch/case
  
   default:printf("\n invalid choice");
   printf("\n Press 'O' or 'o' to continue... or any key to exit...");
   scanf("%s",&p);
   }
   while(p=='o'||p=='O');
   }
   getch();
   return 0;
  }
You've tried to use a do-while loop. Use a simple while loop.

1
2
3
4
5
6
7
8
9
10
11
12
13
while(true)
{
  // ALL THE CODE YOU WANT TO BE LOOPED HERE

  cout << "\n Press 'O' or 'o' to continue... or any key to exit...");
  char input;
  cin >> input;

  if (input == 'O'  || input == 'o')
  {
    break;
  }
}



As it is, I think this is too advanced for you. You need to go back to the basics and learn how to write loops first.
doesn't work too it gives me an error first before crash and it says, unidentified true blah blah. it crash. Any other way?
Last edited on
Seems you are missing a closing brace before while.
You should really learn to format you code properly.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
do
{
  //visual

  //enter an atomic number

  // switch/case
  switch(number)
  {
    case 1:
      // some code
      break;
    default:
      printf("\n invalid choice");
      printf("\n Press 'O' or 'o' to continue... or any key to exit...");
      scanf("%s", &p);
  }

}while (p == 'o' || p == 'O');
When i instert an invalid number it will appear the press... but when i input "O" it just close the window. What should i do? Btw someone suggest me to use exit function because it will return from the start but he doesn't want to teach me. Do you know how to use it?
exit stops the program RIGHT THERE for good, program ends, destructors and such not called. terminate() does the same, except it calls the destructors and cleanups on its way out.

neither is appropriate for 'normal' behavior IMHO. If your program detects a catastrophic failure that cannot be recovered from and can cause real damage if it continues to execute, you use these types of functions. They are often abused by new programmers to quit a program but the correct way to do that is to return in main(). Return (in main) exits the program 'normally' when the program is done doing things and is the correct path to take when behaving 'normally'.

bottom line: do not use exit as a quick and easy way to end your program. Follow the normal flow of the code back home and return gracefully.

----------
what is happening with the provided code is that pressing 'o' stops the press a key code block from executing. in the while loop, it reads in. is it 'o'? yes. Break (loop stops). This puts you back to your main and ends the program without any further stopping (add another cout and cin statement pair at the end of main to see this) and the switch is similar.

you need to add the cout << "this is the end of main, press a key to exit\n" cin >> input; to your main right before return(0).
std::exit() ends the program after performing all clean up operations, except that destructors of objects with automatic storage duration are not called.
https://en.cppreference.com/w/cpp/utility/program/exit

std::terminate() calls the terminate handler; the default terminate handler calls std::abort() which abnormally terminates the program without performing any cleanup.
https://en.cppreference.com/w/cpp/utility/program/abort
I should have looked them up, apologies on the misinfo.
Topic archived. No new replies allowed.