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

Explain the working of Insights of a pass gate ?

682


Explain how Verilog is different to normal programming language?

688


Draw Vds-Ids curve for a MOSFET. Now, show how this curve changes with increasing Vgs.

688


What does the above code synthesize to?

2030


What is Noise Margin? Explain the procedure to determine Noise Margin?

1985






How can you construct both PMOS and NMOS on a single substrate?

4491


For a NMOS transistor acting as a pass transistor, say the gate is connected to VDD, give the output for a square pulse input going from 0 to VDD

951


Draw the Layout of an Inverter?

2054


What is the main function of metastability in vsdl?

610


what are three regions of operation of MOSFET and how are they used?

684


Explain the three regions of operation of a mosfet.

632


What transistor level design tools are you proficient with? What types of designs were they used on?

2882


What are the various regions of operation of mosfet? How are those regions used?

597


Draw the Cross Section of an Inverter? Clearly show all the connections between M1 and poly, M1 and diffusion layers etc?

2860


Give a big picture of the entire SRAM Layout showing your placements of SRAM Cells, Row Decoders, Column Decoders, Read Circuit, Write Circuit and Buffers

644