Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

:= and = whats the diff ?

shockingushockingu Posts: 43Member
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

  • ManningManning Posts: 1,621Member
    : 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.
  • shockingushockingu Posts: 43Member
    : : 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.