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 (93)
 OOPS interview questions  OOPS Interview Questions (562)
 C++ General interview questions  C++ General Interview Questions (459)
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 ?    55 Yes 3 No
Anita Sachdeva
 
Answer
# 2
=----->assignment
== --->comparision
 
Is This Answer Correct ?    41 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 ?    26 Yes 4 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 ?    13 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 ?    5 Yes 3 No
Balveer
 
Answer
# 10
= operator is assignment operator

== is operator comparision two values
 
Is This Answer Correct ?    2 Yes 0 No
Datta Khilari
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
what is the diff b/n c and c++ a. dynamic scoping b. nested switching c. declaration of variables in any code block d. separation of compilation and linking Hughes 2
int f() { int I = 12; int &r = I; r += r / 4; int *p = &r; *p += r; return I; } Referring to the sample code above, what is the return value of the function "f()"? a) 12 b) 15 c) 24 d) 17 e) 30 Quark 2
catch(exception &e) { . . . } Referring to the sample code above, which one of the following lines of code produces a written description of the type of exception that "e" refers to? a) cout << e.type(); b) cout << e.name(); c) cout << typeid(e).name(); d) cout << e.what(); e) cout << e; Quark 2
template<class T, class X> class Obj { T my_t; X my_x; public: Obj(T t, X x) : my_t(t), my_x(x) { } }; Referring to the sample code above, which one of the following is a valid conversion operator for the type T? a) T operator T () { return my_t; } b) T operator(T) const { return my_t; } c) operator(T) { return my_t; } d) T operator T (const Obj &obj) { return obj.my_t; } e) operator T () const { return my_t; } Quark 1
i want to know how to copy arrary without using any method or function. I have tried the below using System; class e4 { static void Main(string[] args) { int a,b; int[ ] m= new int[5]; int[ ] n= new int[5]; for(a=0;a<=4;a++) { Console.WriteLine("enter any value"); m[a]=Convert.ToInt32(Console.ReadLine()); m[a]=n[a]; } for(b=0;b<=4;b++) { Console.WriteLine(n[b]); } } } but it will give wrong result can anyone solve this problem Reliance 1
write a program in c++ to generate imp z y x w v w x y z z y x w x y z z y x y z z y z z   4
write a program that a 5 digit number and calculates 2 power that number and prints it.   2
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); Quark 3
what is data Abstraction? and give example TCS 143
What is Namespace? Samsung 4
How to avoid a class from instantiation? Symphony 8
let a,b,c be three integer numbers.write a c++ program with a function void rotate 1()such that a->b->c and c->a.   1
 
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