I need help with True, False, NOT, AND, OR, I know what they do but how do I use them in code?(btw I am a complete nobbie I just started like 2 days ago...) thanks! :)
Printable View
I need help with True, False, NOT, AND, OR, I know what they do but how do I use them in code?(btw I am a complete nobbie I just started like 2 days ago...) thanks! :)
That's a very open ended question.... You can use them in many, many scenarios..
AND/OR/NOT are represented as operators: &&/||/! respectively.. true and false are both keywords (false represents Zero, and true typically represents One), and are generally the 2 possible outcomes of any expression involving these operators.
Thanks Bench82 but I ment how do I use them in code I know what they do I just dont know how 2 use them... :)
Alright if you know how to use them then what are you doing here?
if you need examples you should know from what your getting the knoledge from.
//Enouph of the flame
Alright here are some examples.
its untested but those are examplesCode:
#include <iostream>//Basic Library
using namespace std;// Namespace for not typing out the whole function like so std::cout//
int main(){// You need int main for compiler even to read this.
int i=0,a=0; // Numbers only Thats 6 digit limit//
bool event; // True and False//
if(i==0 &&/* && means AND*/ a==0){ // example of AND
event=true;// example of True
event=false;//Example of false
}
if(event==true || event==false){ // example of or
i=1;
}
if(i != 0){//Example of Not
cout<<"i does not equal 0"<<endl;// This is Outputing whats inside of quotes//
system("PAUSE");// This pauses the system for you to see ouput //
}
}
OK - well, it's still a very open ended question... You might be better off looking at this tutorial.... http://www.cprogramming.com/tutorial/lesson2.htmlQuote:
Originally Posted by cgsarebeast
I have I need It more explaned basicly
Dude how basic do you need it I just gave you examples!!!
Srry like I said I just started 2 days ago, I dont know how 2 describe it, I guess It would be explaning thanks for ur help i'm a slow learner :)
...........Dude your not slow your just feeble minded .
I dont think no ones going to spoon feed you everything
that example was 2 advance if you can could u break it down (btw I'm only on lesson 3 of this sites help)
dude I am not lazy (well sort of lol :)) but I really am a slow learner and if u cant help me PLEASE dont make comments like that cuz u dont know me or if I am a slow learner or not!
but I do apresheate you help if you wanna give it (srry I'm a VERY bad speller)
Your kidding me if thats to advance then im god.
watch maybe your thinking this is code
//<--- its not those are comments anything after this is commented.
and
/* */ those are also comments anything between these are commented.
I need 2 put 2 -n- 2 tougther for ex. how would I use a True, False, AND, OR, NOT with text.... like how would I combinde the 2 things and it work, I dont know how else 2 desribe it... thanks though :)
right, first off. Learn to spell. if you can't even spell, coding is not for you. But I don't believe you can't spell, I think you're just being lazy.
I'll give you some starters:
- '2' is a number. 'to' is a word. They have different meanings.
- there is no such word in the english language as '-n-'. The word is
'and', and it takes the same amount of time to type!
edit: and if you still can't spell, use a spell checker!
You might think, I'm being pedantic (or just being an ..............), but when you code, if you make a speeling mistock, your code won't work.
as for your question, boolean logic (true, false, and, or, etc) is used to make decisions in a program.
Code:int age = 20;
if (age < 10) // evaluates to true
{
cout << "you are young"; // this means print "you are young" on the screen
}
else if (age >= 10 && age < 20) // this means if the age is greater than 10 AND less than 20
{
cout << "you are an adolescent";
}
O ok I get it better now but I wish ya'll would STOP pestering me I am VERY smart at computers but I am only 16 and If ya'll really have 2 know I have a brain disorder, I am NOT lazy with this I am just a slow learner -n- stuff (and I like shorttype like -n- so thats why I did that) and its not kewl 2 joke OR say stuff about a person that u dont know cuz I am VERY smart I just lack in spellin AND I like shorthand type or whatever u call it...
>>btw I am a complete nobbie
I think this validates ChaosEngine's point best.
Also, as already stated, your question was really open ended -
programming is all about defining a problem in good detail, then
attempting to solve it. If you can't define your problem well for us,
there is no-one who is going to guess what you mean and
produce an answer - meet people half way and they'll be glad to
help, and you won't get flamed by the newest member on the
board ;)
If you still have difficulty understanding after ChaosEngine's post,
for the love of God, Mother Earth, Buddha, Ganesh or whoever
you believe in, DONT reply saying -"sry dn't understand - can you
explain it again plz." Instead, try and isolate what you don't get
and ask a direct question about it.
>>I need 2 put 2 -n- 2 tougther for ex. how would I use a True,
False, AND, OR, NOT with text.... like how would I combinde the 2
things and it work
Instead try something a bit more descriptive:
>>I want my program to do X OR/AND/NOT/IF/UNLESS Y, and i
just don't know how to get off the ground - any ideas?
Naturally, substituting in details of X and Y, and the operation
on the middle!
look I just started and I do NOT know really what C++ is capalbe of so its hard 2 put out examples... could u just give me websites that explane it thanks....
Ok then, we'll break one down together. Suggest a simple
program - and by that i don't mean msn messenger - i mean
something a 4 year old could do (that is not intended as an
insult, learning to program is a lot like learning how to do things
all over again). Something real basic, like swap two numbers or
convert from one currency to another. Just suggest one and we'll
work off it
Are you even trying to understand what is going on in this thread cgsarebeast?
Frst of all - if you cant understand chaos engine's post, then no website will help you.
Second of all - we dont know what you dont understand ... you just keep saying that you dont.
So im wondering whether the idea of using these operators is too high for you, or if it is something else that is slowing you down (i.e the if statements .. or anything else in the code). A question for you: have you compiled a working program yet (i.e. one that shows up a small black box, even though it might disappear)
If you STILL dont understand this, it is clearly too complicated of a subject and you should do something a little simpler (like a Hello World program)Code:int main()
{
int age = 20; //INTEGER AGE is equal to the number 20
if (age < 10)
//If the age is less than 10 (which it isn't because it is 20), execute the code inside of the BRACKETS, in other words display (std::cout << ) "you are young".
{ //BRACKET
std::cout << "you are young"; // this means print "you are young" on the screen
}//BRACKET
else if (age >= 10 && age < 20)
//If the age is less than 10 (else) and if the age is greater than or equal to 10 (age>=10)
//AND (&&) at the same time less than 20 (age<20) then execute code inside of the BRACKETS. In other words, display (std::cout << ) "you are an adolescent".
{//BRACKET
std::cout << "you are an adolescent";
}//BRACKET
}
Nevermind I'll get my friend to help but thanks a lot its just hard 2 explane over the net............ but thanks again!!!! :)
He wants us to spoon feed him like I said earlier. Thier is a reason to help out new programmers but ive never seen someone that cannot understand the most basic of basic if you cant do c++ then go to vb(Means Visual Basics but to me it means Very Basic) probably alot more your thing *lol
so far you've yet to demonstrate that.Quote:
Originally Posted by cgsarebeast
look man, I'm not pestering you for fun. When writing code, you have no room for spelling or grammaticals mistakes.
is not the same asCode:PrintFile(someFile);
This simply won't compile.Code:Prntfile(sme_file);
good for you. Write all the shorthand type you want in your personal notes. However, you are now communicating with other intelligent human beings. As a general rule, we don't like txt-style writing; it's annoying and difficult to read.Quote:
Originally Posted by cgsarebeast
So what? Plenty of 16 year olds write correctly.Quote:
Originally Posted by cgsarebeast
I'm sorry to hear that. But you seem to think that you can overcome this disorder enough to write code, so you should be able to communicate.Quote:
Originally Posted by cgsarebeast