My First If Code, Question? :P
Well I was goofing around in C++ today and I made my first IF code.
Code:
#include <iostream>
int main()
{
std::cout << "Please Enter 1 or 2: ";
int a;
std::cin >> a;
std::cin.ignore();
if (a == 1)
{
std::cout << "You Typed: 1";
}
if (a == 2)
{
std::cout << "You Typed: 2";
}
if (a > 2)
{
std::cout << "You Didn't Type 1 or 2!";
}
if (a < 1)
{
std::cout << "You Didn't Type 1 or 2!";
}
std::cin.get();
return 0;
}
What it's supposed to do is see if you typed 1 or 2 and if you didn't it would tell you so. I wan'ted to know how to restart it all from the start if they didn't type 1 or 2? Can anyone give me some info on how I would go about doing that?
In Visual Basic the IF things where a lot easier for me,
(Sub)
If Blah = Blah Then
(Statement)
End If
(Or ElseIf or Else)
End Sub
In someways the C++ seems faster to me, but really its all the same in code so far for me, since in VB the sub parts are typed for you. :) Just need to get use to the "{" "}" and the "( )" things in C++.
Thanks!