Computer Science, asked by jashuabca03, 10 months ago

Which of the following are incorrect statements?
          1)  if(a==7)   printf("IncludeHelp");
          2)  if(7==a)   printf("IncludeHelp");
        3)  if(a=7)   printf("IncludeHelp");
        4)  if(7=a)   printf("IncludeHelp");

a)  1 and 2.

 

b)  3 only.

 

c)  4 only.

 

d)  2,3 and 4.

Answers

Answered by ankhidassarma9
0

Answer:

2,3 and 4.

Explanation:

  • The conditional statement 'if' always is followed by a test expression in parentheses. Statements followed by 'if' will execute only if the test expression is true.
  • test expressions can have Relational operator like '<','>','<=', '>=','==' or '!='  which compares two values.
  • '=' is an assignment operator that cannot the use for a test expression.
  • In Relational operator , the first operand can't be a constant when the second operand is a variable.

Hence , if(a==7)   printf("IncludeHelp");  is the correct statement.

Answered by mintu78945
1

Answer:

c) 4 only.

Explanation:

The fourth statement is wrong in it. Except it all are correct.

As In C++ language , printf function is used for printing.So in All of these statements it following the rules for the printing function in the  C++ languaging program . But the fourth statement is wrong because in this the Code saying (7=a) .But it would show error if we would run it as numerical value cannot be come first in equalisation of specific function.
Similar questions