I need help... I want to make a program that will ask me a question, and I have to answer with yes or no, and it will put some message...
Help me out a bit, I'm quite new at it.
Code: Select all
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
char a;
cout<<"Silkroad Online Forum is awesome, right?";
cin >> a;
if (a == 'yes')
{
cout<<"Exactly";
}
else if (a == 'no')
{
cout<<"Try again";
// I need some command now, that program returns to first question, help? I heared that someone that uses goto in C++ is bad programer?
}
else
{
cout<<"Try again";
// Need that command now again...
}
getch();
return 0;
}
Code: Select all
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
char a;
cout<<"Silkroad Online Forum is awesome, right?";
cin >> a;
switch (a)
{
case 'yes': cout<<"Exactly"; break;
case 'no': cout<<"Try again"; //need that command, to bring me back to first cout
default: cout<<"Answer with yes or no"; //need that command, to bring me back to first cout
}
getch();
return 0;
}
- I get errors in both programs... I've got few questions ...
- 1. I guess char is too small for what I want, any bigger values for letters?
- 2. if (a == 'yes') in first program, can I do that if I didnt declare "yes" and "no"?
- 3. Case 'yes' - can I write that like that?
- 4. What is void main () for? (or however is it spelled), why dont people use int main() - (int = integer - people dont use only numbers in program or what?)
- 5. Can anyone help me finish program?
- 6. What is that function for looping back?
- 7.Any tips?
Tell me advices / anything you want to share ... I heared about void main() (instead int main()) but I dont know what it means ... so
Any help is appreciated!
<3 SRF







