C
Programming and Technical
Category
main()
[
int x=5;
clrscr();
if(x=4)
printf("%d",x+1);
else
printf("%d",x-1);
getch();
]
please give me a valid reason of your answer m not getting .
Read Solution (Total 10)
-
- i think it gives a error as = is a assignment operator and if is a conditional statement
on changing it in to if(x==4) then ans is 4 - 6 years agoHelpfull: Yes(2) No(0)
- because '=' is an assignment operator which assigns the value 4 to x as above. But for checking if the condition is true we should use the relational operator '==' to compare two values
- 6 years agoHelpfull: Yes(1) No(0)
- It gives error because after main function there must be curly brasses,but in above code they are given square brackets
- 6 years agoHelpfull: Yes(1) No(0)
- guys, output is coming 5,but showing some error if we change the braces then we are getting correct ans 5.i execuated the code
- 6 years agoHelpfull: Yes(1) No(0)
- 4, because x=5 than else statement is run and x is decremnet of 1 so 5-1=4
- 6 years agoHelpfull: Yes(0) No(1)
- Compilation error.... because of the presence of clrscr(); in main function
- 6 years agoHelpfull: Yes(0) No(0)
- when this program is compiled in the compiler it is giving the ans as 5!!!
- 6 years agoHelpfull: Yes(0) No(0)
- when we give assignment operator by default the condition will be true and x will be assigned to 4 so after incrementing the answer will be 5.
- 6 years agoHelpfull: Yes(0) No(0)
- This program is compile time error because always main() function block represent by second bracket ( { ) and close will be second bracket ( } ) but here main() function block represent third bracket ([ ]).so, program is error.and if statement (condition) use of compare of multiple variable's values but here if statement (condition) is assign 4 to x (x=4) so,this program 2 errors. Thank You
- 5 years agoHelpfull: Yes(0) No(0)
- It's programme any thing not print because continue keyword running until 4 and when goes 5 then break means control exit from if statement so any thing not print
- 5 years agoHelpfull: Yes(0) No(0)
C Other Question
programming coading
find the next biggest number
8,4,2,9,6,3
ans:8->9,4->2,2->3,9->,6->8,3->4