How To Repeat It?????

How To Repeat that program many many times???


#include<iostream.h>
#include<conio.h>
#include<cstring.h>
class quiz
{
public:
void choice()
{
string choice;
cout<<"The Abbrivation Of:";
cin>>choice;
if(choice=="IP")
cout<<"Internet Protocol";
if(choice=="ip")
cout<<"Internet Protocol";
else if(choice=="OOP")
cout<<"Object Oriented Programming";
else if(choice=="oop")
cout<<"Object Oriented Programming";
else if(choice=="SAD")
cout<<"System Analysis And Design";
else if(choice=="sad")
cout<<"System Analysis And Design";
else if(choice=="TCP")
cout<<"Transfer Control Protocol";
else if(choice=="LAN")
cout<<"Local Area Network";
else if(choice=="lan")
cout<<"Local Area Network";
else if(choice=="WAN")
cout<<"Wide Area Network";
else if(choice=="wan")
cout<<"Wide Area Network";
else if(choice=="MAN")
cout<<"Metropolian Area Network";
else if(choice=="man")
cout<<"Metropolian Area Network";
else if(choice=="DBA")
cout<<"Data Base Administrator";
else if(choice=="dba")
cout<<"Data Base Administrator";
else if(choice=="RAM")
cout<<"Random Access Memory";
else if(choice=="ram")
cout<<"Random Access Memory";
else if(choice=="ROM")
cout<<"Read only Memory";
else if(choice=="rom")
cout<<"Read only Memory";
else if(choice=="TCP")
cout<<"Transfer Control Protocol";
else if(choice=="tcp")
cout<<"Transfer Control Protocol";
else
cout<<"!!WRONG ENTRY!!\n";

}
};
void main()
{

cout<<endl;
cout<<"\t\t ^^^-^^^-^^^-^^^-^^^-^^^-^^^-^^^-^^^-^^^-^^^\n";
cout<<"\t\t ^^^^^^^ WELCOME T0 \"IT Acronym Quiz\" ^^^^^^\n";
cout<<"\t\t ^^^-^^^-^^^-^^^-^^^-^^^-^^^-^^^-^^^-^^^-^^^\n\n";
cout<<endl;
cout<<"**************ENTER FROM THE FOLLOWING ABRIVATIONS**************"<<endl;
cout<<endl;
cout<<"*******[TCP],[SAD],[RAM],[ROM],[DBA],[IP],[TCP],[LAN],[MAN],[WAN]!!!!**********"<<endl;
cout<<endl;
quiz h;
h.choice();
getch();


}
a loop.

1
2
3
4
5
6
7
int main(){
   while(true){
      //do your stuff here
      if(cin.get() == 'q') break;//a way to get out.
   }
   return 0;
}


main is int and returns 0. conio.h is not standard.
you use string class without including <string>
you neither add std:: to cin, cout and string nor use namespace std.
in choice function you could iterate through string and change all letters to lowercase (function is tolower).
you could also use an std::map.
You could also use the goto command :)

1
2
3
4
5
6
7
8
9
10
int main ()
{
start:

// your main code here

goto start;

return 0;
}


In small programs this might be a good/easy way to do it.
But if you decide to go to more complicated progs, you should use something else, 'cause goto can make progs really hard to understand ^^

Hope this helped :)
Even that way, scoping of variables can become an issue, and in any case, really, goto makes things hard to read. It is archaic and belongs in a museum, leave it there. Use loops.
Topic archived. No new replies allowed.