ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  C++ General
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
What is the difference between = and == in C?
 Question Submitted By :: Alok Hisaria
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference between = and == in C?
Answer
# 1
=----->assignment
==  --->comparision
 
Is This Answer Correct ?    0 Yes 0 No
Dee
 
  Re: What is the difference between = and == in C?
Answer
# 2
= operator in C language is used to assign the value of 
right-hand side value/variable/expression to the left hand 
side variable.

== operator in C/C++ language is used to check the value of 
left hand variable/expression with the right hand 
variable/expression. whether the two values are equal or 
not. It returns true if these are equal else it will return 
false.
 
Is This Answer Correct ?    1 Yes 0 No
Anita Sachdeva
 
 
 
  Re: What is the difference between = and == in C?
Answer
# 3
1. First of all = is a assignment operator and == is a 
comparision operator
2.= give you the same vale like x=y means if x=5 then y=5
on the otehr hand if x==y then it will give you the true or 
false
eg if x==5
y==5 
then return true
 
Is This Answer Correct ?    0 Yes 1 No
Sunita
 
  Re: What is the difference between = and == in C?
Answer
# 4
= is the assigment operator

=is used to copy 
ex:
a=5 means, copy just that value for 'a'.
== is comparision operator
ex:

#include<stdio.h>
void main()
{
int a;
scanf("%d",&a);
if(a==5)
printf("welcome");
else
printf("if the is not equal to 5");
}
 
Is This Answer Correct ?    1 Yes 0 No
K.s. Karthick Prabu
 
  Re: What is the difference between = and == in C?
Answer
# 5
== assignment operator
= equal to
 
Is This Answer Correct ?    0 Yes 1 No
Varsha Vilas Kalebag
 
  Re: What is the difference between = and == in C?
Answer
# 6
= 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 ?    1 Yes 0 No
Chandan
 
  Re: What is the difference between = and == in C?
Answer
# 7
=  it is used to assign a variable
== it is used to comparison of vale
 
Is This Answer Correct ?    1 Yes 0 No
Srabani
 
  Re: What is the difference between = and == in C?
Answer
# 8
= is assignment operator. It is used to assigne a value to a
variable.
and == is a comparison operator is is used to compare to values.
 
Is This Answer Correct ?    1 Yes 0 No
Vaibhav Meena
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
const char * char * const What is the differnce between the above two? TCS8
what is the order of initialization for data? TCS4
How to write Multithreaded applications using C++? Honeywell2
What is the difference between a copy constructor and an overloaded assignment operator? Microsoft3
What is virtual constructor paradigm? HP3
Is there something that we can do in C and not in C++? Patni6
Can inline functions have a recursion? Give the reason?  1
Which of the Standard C++ casts can be used to perform a ?safe? downcast: a) reinterpret_cast b) dynamic_cast c) static_cast d) const_cast Quark1
What is object slicing and how can we prevent it? Tech-Mahindra2
why we cant create array of refrences  2
Explain about profiling?  1
class Foo { int x; public: Foo(int I); }; If a class does not have a copy constructor explicitly defined one will be implicitly defined for it. Referring to the sample code above, which one of the following declarations is the implicitly created copy constructor? a) Foo(Foo *f); b) Foo(Foo &f); c) Foo(const Foo *f); d) Foo(const Foo &f); e) Foo(int); Quark3
Definition of class?  10
Which uses less memory? a) struct astruct { int x; float y; int v; }; b) union aunion { int x; float v; }; c) char array[10]; Quark3
Can we have "Virtual Constructors"? TCS5
Implement strcmp Citadel2
Shall we use 'free' to free memory assigned by new, What are the further consequences?? Symphony4
string somestring ; Which of the following choices will convert a standard C++ string object "somestring" to a C string? a) Copy.somestring () ; b) somestring.c_str () c) &somestring [1] d) std::cstring (somestring) e) (char *) somestring Quark1
How would you stop a class from class from being derived or inherited?The constructer should not be Private,as object instantiation should be allowed.  14
What are the differences between a struct in C and in C++? Wipro4
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com