![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| ||||
| Variables Ok, so thanks to you guys I finnaly started to learn C++ but I'm confused about the variables, do they not have anything to define that it's a variable? (Eg %,$) |
| |
| ||||
| well.. you can also use Code: cout << "1" << endl; cout << "2" << endl; ![]() don't forget to use std namespace Code: using namespace std; |
| The Following User Says Thank You to HelloWorld For This Useful Post: | ||
MrPickle (11-20-2007) | ||
| ||||
| Thank you, I now have another question haha. How would you go to a previous point? Example: Code: //that stuff (iostream and whatnot) don't know off the top of my head atm.
int main(){
int a,b;
string name;
cout
<< "Hello, What's your name? \n";
getline(cin,name);
cout
<< "Please enter a value" << name << ".\n";
getline(cin,a);
cout
<< "Please enter another value.";
getline(cin,b);
if(a == b){
cout
<< "a = b";
return 0;
} else {
cout
<< "Try again";
//Now it would go back to the second cout?
}
} |
| ||||
| Code: #include <iostream>
using namespace std;
int main()
{
string name;
int a, b;
cout << "Enter your name: ";
cin >> name;
cout << "Enter a: ";
cin >> a;
do
{
cout << "Enter b: ";
cin >> b;
} while (b != a);
} |
| The Following User Says Thank You to HelloWorld For This Useful Post: | ||
MrPickle (11-20-2007) | ||
| ||||
| Just do a quick check on the name variable, if it is <> to "" then loop from the point after the name input else start before the name input. |
| ||||
| Woo hoo! Thanks!! Quote:
On a different subject, is there a way to prevent the command prompt from closing? EG make it close when you press Enter? __________________ PM me and tell me your name or a phrase and I shall write it in Elf for you. English Tengwar to be precise. ![]() Last edited by MrPickle : 11-20-2007 at 11:11 AM. Reason: Lee posted =D |
![]() |
| Thread Tools | |
| Display Modes | |
| |