Identify the incorrect one1.if(c=1)2.if(c!=3)3.if(a<b)then4.if(c==1)A. 1 onlyB. 1&3C. 3 onlyD. All of the above

This question is related to TCS Interview

Showing Answers 1 - 59 of 59 Answers

Sreehari

  • Oct 17th, 2006
 

Hi its answer is  a 1 only

because the condition to check must use == 

  Was this answer useful?  Yes

shiva

  • Aug 10th, 2011
 

B

  Was this answer useful?  Yes

prasad

  • Aug 14th, 2011
 

if(c=1) is wrong because
'=' is used as assignment operator.

  Was this answer useful?  Yes

rohit

  • Aug 14th, 2011
 

ans is 3 then is not allowed
1 is right becoz compiler take it as (c=1)!=0
so firstly it assign the value 1 to see and check

  Was this answer useful?  Yes

ashritha kandhi

  • Aug 17th, 2011
 

B.becoz as c is equals to 1 as said in option d so, from we know that 1 is wrong answer.and in 3rd option it is mentioned that a < b which means that option 1 value is grater than option 2.

the correct answer is B

  Was this answer useful?  Yes

wasim

  • Aug 17th, 2011
 

B is the answer because
1. in if(c=1) if c=1 then we can write as c==1 and
2. in if(a

  Was this answer useful?  Yes

pawanbhardwaj

  • Aug 22nd, 2011
 

Ans- a is incorrect statement that's if(c=1)
because condition check is if(c==1);

Code
  1. void main()

  2. {

  3. int c;

  4. scanf("%d",&c);

  5. if(c==1)

  6. printf("this no.");

  7. }

  Was this answer useful?  Yes

Strictly speaking, only 3 is incorrect in terms of being a syntax error (C doesn't have a "then" keyword).
1 is most likely a coding error since it will always evaluate to true, but it's not disallowed. You can test on the result of an assignment expression, such as "if (s = fgets(buf, sizeof buf, stdin))", although some of the smarter compilers will throw up a warning on it.

  Was this answer useful?  Yes

sparkre

  • Aug 24th, 2011
 

Answer is option A)A only.
In C, if(c=1) the statement is considered as error because c=1 is an assignment statement and not a statement which can be written inside if condition

  Was this answer useful?  Yes

ramana gprec

  • Sep 6th, 2011
 

ans:-
1 and 3 are wrong
thee is no double equal in 1
and then key word in 3

  Was this answer useful?  Yes

RONAK

  • Sep 10th, 2011
 

Answer is Option B, 1 and 3 are incorrect as first option uses assignment operator which is not right and the third option has wrong syntax as "THEN" is not used.

  Was this answer useful?  Yes

PAVAN KUMAR

  • Sep 13th, 2011
 

C

Code
  1. a=3,b=4

  2. a=(a+b)-(a=b);

  Was this answer useful?  Yes

shubham

  • Sep 14th, 2011
 

a)bcz the correct syntax is if(c==1)

  Was this answer useful?  Yes

SURLA GOVINDU

  • Sep 14th, 2011
 

Ans is 1 only because in if condition there is no use of assignment operator

  Was this answer useful?  Yes

namu

  • Sep 15th, 2011
 

Ans. is option 'A'- 1 only

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions