cse-icons 0 Report post Posted October 20, 2004 Hi chk this code....int i, n = 20; for (i = 0; i < n; i--)printf("-");You have to print '-' 20 times. by adding or removing or replacing onlya single character from the code.There are 3 possible solutions for the above question. Can u get them? Share this post Link to post Share on other sites
dawu 0 Report post Posted October 20, 2004 change -- to ++ Share this post Link to post Share on other sites
cse-icons 0 Report post Posted October 21, 2004 If u change from -- to ++ then,that wud be changing 2 characters.. whereas it is allowed to add/delete/replace only a single character. Share this post Link to post Share on other sites
dawu 0 Report post Posted October 21, 2004 ok here it is, change i-- to n--, that wasn't so hard man Share this post Link to post Share on other sites
dawu 0 Report post Posted October 25, 2004 well I can try, but you have to try also...I'll get started tonight Share this post Link to post Share on other sites
cse-icons 0 Report post Posted October 26, 2004 hi,actually i tried it few days back and got the solutions(2 by me and one by a friend),found it interesting and so posted it here.. Share this post Link to post Share on other sites
jjhou 0 Report post Posted November 3, 2004 yeah, that is one solution and probably the simplest one.But as i told u there are 3 solutions in all. Can u figure out the other two?should take a little more time than the earlier one Share this post Link to post Share on other sites
mizako 0 Report post Posted November 11, 2004 Hi,Without changing anything it prints already "-" twenty times and much more. I suppose it has to print exactly twenty times. right? Share this post Link to post Share on other sites
sunilr_74 0 Report post Posted November 12, 2004 int i, n = 20; for (i = 0; i < n; i--) printf("-"); Â Â You have to print '-' 20 times. by adding or removing or replacing only a single character from the code. There are 3 possible solutions for the above question. Can u get them? <{POST_SNAPBACK}> here goes:1. replace i with n in the for() loop 2. make it -i < n 3. in for() loop init i as 40 (for(i=40;i < 20 ... ) Â so there :-) Share this post Link to post Share on other sites
rowita 0 Report post Posted November 12, 2004 sunilr no.3 is not correct!cse_icons , you sure there's another way!? Share this post Link to post Share on other sites
cse-icons 0 Report post Posted November 13, 2004 yeah, there are 3 solutions all-right...i will post all the solutions in my next reply... got to go now....bye.... Share this post Link to post Share on other sites
cse-icons 0 Report post Posted November 13, 2004 hi all,here are the 3 solutions, in case you still want to give it a try.. dont look at the solutions below: int i, n = 20; [br]for (i = 0; i < n; n--)[/br]printf("-"); int i, n = 20; [/br]for (i = 0; -i < n; i--)[br]printf("-"); int i, n = 20; [/br]for (i = 0; i + n; i--)[/br]printf("-"); Share this post Link to post Share on other sites
rowita 0 Report post Posted November 14, 2004 Good Logical solution in third method i like that , thanks Share this post Link to post Share on other sites