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

Answer Posted / swapna

= is used for assigning the value to a variable
for example
int a=10;
if a=5
printf("%d",a);
else
printf("%d",a);

output:5
in this program a value is assigned to 5 and 5 is printed.

whereas
== is used to check the value of the variable
for example
int a=10;
if a==5
printf("%d",++a);
else
printf("%d",a);

output:10

in this value of a is checked with 10 .If it is equal if
stmt is true and a is incrementd and printed.
If it is not equal a value is printed.

Is This Answer Correct ?    14 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What's the price in 1K quantity?

2388


What work have you done on full chip Clock and Power distribution? What process technology and budgets were used?

2743


Are you familiar with the term MESI?

2115


Insights of a 4bit adder/Sub Circuit?

2847


why is the number of gate inputs to CMOS gates usually limited to four?

800






Explain the Charge Sharing problem while sampling data from a Bus?

4178


Explain what is scr (silicon controlled rectifier)?

617


What is the ideal input and output resistance of a current source?

2515


Write a VLSI program that implements a toll booth controller?

3498


What happens if we use an Inverter instead of the Differential Sense Amplifier?

2477


Explain what is the use of defpararm?

657


Process technology? What package was used and how did you model the package/system? What parasitic effects were considered?

2641


Explain how Verilog is different to normal programming language?

682


what is the difference between the TTL chips and CMOS chips?

579


Explain how MOSFET works?

2806