Nov 27, 2010 at 1:22pm UTC
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();
}
Nov 27, 2010 at 8:09pm UTC
1 2 3 4 5 6
int main()
{
begin:
//code goes here
goto begin;
}
or
1 2 3 4 5 6 7
int main()
{
while (1)
{
//code goes here
}
}
and some compilers support
1 2 3 4 5
int main()
{
//code goes here
return main();
}
Last edited on Nov 27, 2010 at 8:09pm UTC
Nov 27, 2010 at 8:29pm UTC
1) Evil, that's not what goto is for.
2) Good
3) Non-standard, you aren't allowed to call main() ever
Nov 29, 2010 at 6:10pm UTC
@firedraco
I know I've heard its bad a million times. But what exactly is wrong with it, other than personal preference? I mean technically, how is it different from a while loop?
Nov 29, 2010 at 8:16pm UTC
It's bad because there is a while loop, which you should use instead.
Nov 29, 2010 at 8:57pm UTC
Sorry, that doesn't really answer my question.
Nov 29, 2010 at 9:09pm UTC
It is probably the same as a while loop, but the main issue is that it can easily lead to spaghetti code that you understood when you wrote it, but not 2 months later. It also is ambiguous since your goto could be a loop, a jump, a return, etc. Another issue is that it does not have scope so you could theoretically skip constructors or initializations of variables or other things.