What is the difference between = and == in C?

Answer Posted / chandan

= Assignment Operator
== Comparision Operator

One Intresting Difference between these two is in the =
operator the left side can not be a const, while in == we
can place Const in either side.
eg. x = 5 //correct
5 = x // Incorrect

but X == 5 // CORRECT
5 == X // Correct and Preffered to use left value
as constant to avoid the unwanted bug.

Is This Answer Correct ?    46 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain explicit container.

630


If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?

661


Are there any special rules about inlining?

577


Is c++ a float?

596


When should I use unitbuf flag?

580






When we use Abstract Class and when we use Interface?where we will implement in real time?

1662


What is the basic of c++?

592


What is prototype in c++ with example?

554


Are strings immutable in c++?

648


Why is c++ considered difficult?

637


What is increment operator in c++?

554


Can we specify variable field width in a scanf() format string? If possible how?

654


When do we run a shell in the unix system?

558


Will a catch statement catch a derived exception if it is looking for the base class?

554


Which header file allows file i/o with streams a) fileio.h b) iostream.h c) fstream.h

649