Thread: question about assigment

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    96

    question about assigment

    iam totally noob can someone tell me what the difference is? and how is it difference
    Code:
     x=5;            
     y==10;

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I've got some questions as well.

    Where is your 'C' book?

    Have you read it?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    71
    Why have you posted twice?

    x=5; =>x holds the value of five (5)
    y==10 => "==" represents the mathematical sign for equality(=) ,is mainly used in "if"

    I hope you understand

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by mouse666666 View Post
    iam totally noob can someone tell me what the difference is? and how is it difference
    Code:
     x=5;            
     y==10;
    x = 5 ... is assignment. It places the value of 5 in the variable x.

    x == 5 ... is a test for equality. It generates true if x holds the value 5 or false if it does not.

    This should be very early in our C documentation.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Nice - enable the lazy poster to come back again with the next dumb "read the book for me" post
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    If you can't remember something that simple, it might be time to consider a different path.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Salem View Post
    Nice - enable the lazy poster to come back again with the next dumb "read the book for me" post
    Gee... sorry... I was just answering a question...

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Yeah "totally noob" with over 90 posts and has been posting for the thick end of a year.

    In other words, you really ought to have some basics sorted out by now, like where to look up things like this.

    Cease Enabling Behavior
    Nothing is gained from simply spoon-feeding a trivial answer that 100's of people here could have answered right away.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Salem View Post
    Nothing is gained from simply spoon-feeding a trivial answer that 100's of people here could have answered right away.
    I guess I'm just having a hard time forgetting how stuck I was on OOP until just the other day when I asked a bunch of worse than noob questions... Turns out the missing pieces were profoundly basic information... Classes are prototypes for Objects. Objects are types. They're basically structs. Messages are function calls. That kind of thing that I guess most tutorial writers figure are we should already know. I'm still beaming in gratitude for the help I got... that was amazing!

    You know what... sometimes people just get stuck on something and need a little nudge.
    Now if this was the 5th time in a couple of days, that might be different...

  10. #10
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    OOP can't be learned on page 10 of a book on C, unlike assignment vs equality.

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by User Name: View Post
    OOP can't be learned on page 10 of a book on C, unlike assignment vs equality.
    I take it then, you've never had some relatively simple thing blocking your way... that one fact that doesn't make any sense to you until it's explained... I can attest to how frustrating it can be... The only thing between me and learning C++ was a couple of simple facts that just somehow weren't sinking in... Once I realized that a Class is basically a struct, I was off to the races... Now on chapter 4 and learning fast... One little thing was all that was in the way.

    I'm willing to give the OP the benefit of the doubt... = vs == might have been his "one little thing" and I didn't mind helping him out at all.

    I'm sorry this has turned out to be controversial... I was just trying to be nice to the guy.

  12. #12
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Quote Originally Posted by CommonTater View Post
    I take it then, you've never had some relatively simple thing blocking your way... that one fact that doesn't make any sense to you until it's explained... I can attest to how frustrating it can be... The only thing between me and learning C++ was a couple of simple facts that just somehow weren't sinking in... Once I realized that a Class is basically a struct, I was off to the races... Now on chapter 4 and learning fast... One little thing was all that was in the way.

    I'm willing to give the OP the benefit of the doubt... = vs == might have been his "one little thing" and I didn't mind helping him out at all.

    I'm sorry this has turned out to be controversial... I was just trying to be nice to the guy.
    Your response contained no more information than any resource, such as textbook or a tutorial on this website, would.

    From Lesson 1: The Basics of C of the "Getting Started" tutorial of this very site.
    Code:
    
    a = 4 * 6; /* (Note use of comments and of semicolon) a is 24 */
    a = a + 5; /* a equals the original value of a with five added to it */
    a == 5     /* Does NOT assign five to a. Rather, it checks to see if a equals 5.*/
    Yes, there's been plenty of times I've been stuck very on stupid stuff. I dare say, some even worse than this. But when I have, it's after actually attempting to learn it.

    I don't intend to abrade you, CommonTater, or anyone else for that matter. I'm just trying to show this is, in fact, not a reasonable question. I respect you for trying to be helpful, but sometimes that does more harm than good.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question bout my work
    By SirTalksAlots in forum C Programming
    Replies: 4
    Last Post: 07-18-2010, 03:23 PM
  2. A question about a question
    By hausburn in forum C++ Programming
    Replies: 3
    Last Post: 04-25-2010, 05:24 AM
  3. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM