Code:void main(){ int a; a=5; if(a=15) printf("welcome%d",a); else printf("hello%d"a); }
why output is welcome15 ?
Code:void main(){ int a; a=5; if(a=15) printf("welcome%d",a); else printf("hello%d"a); }
why output is welcome15 ?
Because "a=15" and "a==15" do very different things...
Devoted my life to programming...
but what exactly a=1 do? i know what the function == does but what about = ? how it works?
can anyone give me your whatsapp number ? so i can ask and explain you more briefly?
i have a list of unsolved programs who want to help me?
that programs are easy... just of 5 or 6 lines so experts can solve in within 10 min.
plz guys reply....im waiting...
Last edited by san12345; 02-27-2016 at 06:46 AM.
Hi San,
'=' is assignment operator(It will put the value form RHS to LFS).
'==' is comparison operator.(It will compair the RHS and LHS value. If the value matches then only it will be true. else It won.t be true.
Here in your case a = 15 is assigning 15 to a. So, because of this assignment the condition in if will always be true. You are getting welcome15.
ohh yes!! thx for reply
Why do you have this list of "unsolved" programs? What is your goal behind getting people to "solve" these programs for you?Originally Posted by san12345
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I want to bring out of marks in my collage exam
So I want to learn c program from basic
That's why I'm asking questions
I suggest that you take a more structured approach to basic learning: work through an introductory book or tutorial. At the moment, you seem to lack the fundamental skills to be able to investigate these problems successfully. Therefore, you will only end up getting piecemeal trivia that is unlikely to help you actually develop programming problem solving skills.Originally Posted by san12345
After properly going through structured introductory material, you should have the skill to be able to solve many of these problems by yourself. At that point, for those problems that you cannot solve or are unsure of the solution, you can come back here, explain what you tried, and then get useful feedback.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)