![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Bear in mind that switch is not necessarily a substitute for the if/else/elseif type of construct:
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#12 | |
|
Programmer
Join Date: Jan 2006
Location: Texas
Posts: 36
Rep Power: 0
![]() |
Quote:
so basically what i need is that and if( x != y && x != a && x != b && x != c )
{
// ...
}replace the //.... if( x == y && x == a && x == b && x == c )
{
// put (variable) on a list
}if( x != y && x != a && x != b && x != c )
{
// ignore (variable)
}all i need to know is how to place it on a list... after that the next page will be like cout<<"All contain: \n"; // displays list two more questions... how to i say "x = whatever"... i know how to say "x = a number" but i need "x = a word" int x = (10) cout<<x; and one more thing... does && mean "and" or "and/or" Thanks Last edited by jobobshishkabob; Feb 16th, 2006 at 10:26 PM. |
|
|
|
|
|
|
#13 |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 214
Rep Power: 0
![]() |
this guy is so funny ..HAHAHAHAHAHA
quote "Frankly, if you can't express yourself clearly to a human, how do you expect to express yourself clearly to your machine?... "i want to set them all aside in a side in a list." Say that out loud to yourself and see if you "get it." (DaWei) |
|
|
|
|
|
#14 |
|
Newbie
Join Date: Feb 2006
Posts: 11
Rep Power: 0
![]() |
There are different types of variables. The 'int' variable can only hold integers up to a certain value. Some other types of variables are 'char' and 'float'.
A 'char' variable can hold a single, 8-bit (well, 8-bit on almost all current architectures, anyway) character such as the lower-case letter 'a', upper-case 'A' or the question mark '?' symbol. Example: char foo = 'Y'; A 'float' variable can hold irrational numbers like 3.14159 and 2.71828. It has limited precision, but should be enough for most purposes. A 'double' has greater precision. Example: float bar = 3.14159; A 'string' is a class from the C++ standard library that is capable of holding a string of characters, for example, "a word, or even words separated by spaces and punctuation". Example program using strings: #include <iostream>
#include <string>
using namespace std;
int main()
{
string name = "babbling";
cout << name << endl;
return 0;
}Don't use '\n' in C++, because it will not work as expected on all platforms. If you use "endl", it will produce nothing more and nothing less than a new line on all platforms. I recommend you get a good C++ book, because you have a lot of stuff to learn about. "The C++ Programming Language" by Bjarne Stroustrup isn't a very easy read, but it will make you a better C++ programmer than any other book will. Once you have read and understood the basics, it also becomes easier to read. Good luck!
__________________
Canonical Books: The best programming books around. |
|
|
|
|
|
#15 | |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
Quote:
|
|
|
|
|
|
|
#16 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
Oh, and && is just strictly and. Use || for or, which is probably what you want, unless you use !=
|
|
|
|
|
|
#17 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
Don't babble so much and stick to the facts. Like Jimbo said, endl flushes the stream. Jimbo I don't know what you mean by 'strictly and', just to be clear to the others: && is 'logical AND', whereas & is 'bitwise AND'.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|