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
What's the price in 1K quantity?
What work have you done on full chip Clock and Power distribution? What process technology and budgets were used?
Are you familiar with the term MESI?
Insights of a 4bit adder/Sub Circuit?
why is the number of gate inputs to CMOS gates usually limited to four?
Explain the Charge Sharing problem while sampling data from a Bus?
Explain what is scr (silicon controlled rectifier)?
What is the ideal input and output resistance of a current source?
Write a VLSI program that implements a toll booth controller?
What happens if we use an Inverter instead of the Differential Sense Amplifier?
Explain what is the use of defpararm?
Process technology? What package was used and how did you model the package/system? What parasitic effects were considered?
Explain how Verilog is different to normal programming language?
what is the difference between the TTL chips and CMOS chips?
Explain how MOSFET works?