ALLInterview.com :: Home Page            
 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                      
Google
   
 
Categories >> Software >> Programming Languages >> C++ >> C++ General
 
 


 

 
 STL interview questions  STL Interview Questions (91)
 OOPS interview questions  OOPS Interview Questions (558)
 C++ General interview questions  C++ General Interview Questions (458)
Question
What is the difference between = and == in C?
 Question Submitted By :: C++-General
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
= 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 ?    53 Yes 3 No
Anita Sachdeva
 
Answer
# 2
=----->assignment
== --->comparision
 
Is This Answer Correct ?    39 Yes 4 No
Dee
 
 
 
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 ?    25 Yes 3 No
Sunita
 
Answer
# 4
= 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 ?    12 Yes 2 No
Chandan
 
Answer
# 5
= it is used to assign a variable
== it is used to comparison of vale
 
Is This Answer Correct ?    10 Yes 1 No
Srabani
 
Answer
# 6
= 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 ?    10 Yes 3 No
K.s. Karthick Prabu
 
Answer
# 7
= is used to assign the values to the variables.

Eg:- int a=5,b;
b=a;

== is used for comparison purpose.

Eg:- if(a==b)
continue;
 
Is This Answer Correct ?    8 Yes 1 No
Mallika
 
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 ?    7 Yes 3 No
Vaibhav Meena
 
Answer
# 9
give the new ans 
Is This Answer Correct ?    4 Yes 3 No
Balveer
 
Answer
# 10
= this is assignment operator.it is used to assign a
variable to variable and assign a value to variable.
== this is comparison iperator.it is used to compare any
two variable and values.
 
Is This Answer Correct ?    1 Yes 0 No
Nila
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
Evaluate: int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7); a) 10 b) 11 c) 1 Quark 4
How the compilers arranges the various sections in the executable image?   1
What is object slicing and how can we prevent it? Tech-Mahindra 2
What is problem with Runtime type identification?   2
What is size of a empty class? Microsoft 6
What is Pure Virtual Function? Why and when it is used ? Lucent 9
write a program to add two numbers without using an arithmetic operator. NIIT 1
which is the easy way to divide any integer by 2? Persistent 2
What is the use of static functions? Symphony 10
Please post the model question paper of hal?   2
Badboy is defined who has ALL the following properties: 1. Does not have a girlfriend and is not married. 2. He is not more than 23 years old. 3. The middle name should be "Singh" 4. The last name should have more than 4 characters. 5. The character 'a' should appear in the last name at least two times. 6. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers   1
Write a function which takes a character array as input and reverses it in place. Lehman-Brothers 2
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com