:= and = whats the diff ?

I know this sounds stupid, but im a bit new to pascal as doing for my college course.
I dont have a clue why some times i have to put = and other times i have to put := what is the difference.
Heres a bit of code as an example

[CODE]var num : integer;
begin
num := 1;
if num = 1 then
begin
writeln('wow');
delay(500);
end
end.[/CODE]

if I had changed the "num := 1;" to "num = 1;" then I would get an error. yet in the if statement it uses the := I do kind of know when to use them but dont know why and what it does.
thanks for your replies :-D
--------------------------------
A C++ noobie, and loving it :P.
If post in C++ message board,
I have Borland C++ BuilderX
Enterprise Edition V1.0
--------------------------------

Comments

  • : I know this sounds stupid, but im a bit new to pascal as doing for my college course.
    : I dont have a clue why some times i have to put = and other times i have to put := what is the difference.

    := is the assignment operator. So when you want to assign a value to a variable, you use :=.

    = is the comparison operator. So if you want to see if one variable is equal to some value, you use =.

    It's kind of similar to C/C++, except in that case = is the assignment operator and == is the comparison operator.
  • : : I know this sounds stupid, but im a bit new to pascal as doing for my college course.
    : : I dont have a clue why some times i have to put = and other times i have to put := what is the difference.
    :
    : := is the assignment operator. So when you want to assign a value to a variable, you use :=.
    :
    : = is the comparison operator. So if you want to see if one variable is equal to some value, you use =.
    :
    : It's kind of similar to C/C++, except in that case = is the assignment operator and == is the comparison operator.
    :

    I get it now, the := is like = in C++ and the = is like == in C++
    that was nicely answered for me :)
    --------------------------------
    A C++ noobie, and loving it :P.
    If post in C++ message board,
    I have Borland C++ BuilderX
    Enterprise Edition V1.0
    --------------------------------

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories