- **C++**
(*http://www.velocityreviews.com/forums/f39-c.html*)

- - **Question**
(*http://www.velocityreviews.com/forums/t285235-question.html*)

QuestionHi All,
I have the following problem please help me in solving this. #include <stdio.h> main() { int i, n=20; for(i=0;i<n; i--) { printf("-"); } } Only one character in the above needs to be modified such that the character '-' will be printed 20 times. People say there are 3 ways of doing it but i could figure out only one way given below. #include <stdio.h> main() { int i, n=20; for(i=0;i<n; n--) { printf("-"); } } Can someone crack the other 2 possibilities. regards, Venkat |

Re: Question> Can someone crack the other 2 possibilities.
Here is one: for(i=0;-i<n; i--) |

Re: Question"Niels Dybdahl" <ndy@fjern.detteesko-graphics.com> wrote in message
news:412def76$0$182$edfadb0f@dtext02.news.tele.dk. .. > > Can someone crack the other 2 possibilities. > > Here is one: > > for(i=0;-i<n; i--) > Niels thanks for a quick response, the 2nd possibility is for(i=0;i<n;n--) we just need the 3rd one. |

Re: QuestionVenkat wrote:
> "Niels Dybdahl" <ndy@fjern.detteesko-graphics.com> wrote in message > news:412def76$0$182$edfadb0f@dtext02.news.tele.dk. .. > >>>Can someone crack the other 2 possibilities. >> >>Here is one: >> >>for(i=0;-i<n; i--) >> > > > Niels thanks for a quick response, the 2nd possibility > > is for(i=0;i<n;n--) > > we just need the 3rd one. for(i=0;i+n; i--) Victor |

Re: Question"Venkat" <venkat_kp@yahoo.com> wrote:
> > #include <stdio.h> > main() > { > int i, n=20; > for(i=0;i<n; i--) > { > printf("-"); > } > } > > Only one character in the above needs to be modified such that the character > '-' will be printed 20 times. > People say there are 3 ways of doing it but i could figure out only one way > given below. > > for(i=0;i<n; n--) for (i=0;i+n; i--) PS. I don't think "for (i=0;-i<n; i--)" counts because that is adding a character, not changing one. Did you quote the original problem exactly? If it were "for(i=0; i<n; i--)" then you could change the space to a minus. |

Re: Question"Venkat" <venkat_kp@yahoo.com> wrote in message news:<1093531576.117124@sj-nntpcache-3>...
> "Niels Dybdahl" <ndy@fjern.detteesko-graphics.com> wrote in message > news:412def76$0$182$edfadb0f@dtext02.news.tele.dk. .. > > > Can someone crack the other 2 possibilities. > > > > Here is one: > > > > for(i=0;-i<n; i--) > > > > Niels thanks for a quick response, the 2nd possibility > > is for(i=0;i<n;n--) > > we just need the 3rd one. Piece of cake: #include <stdio.h> main() { int i, n=20; for(i=0;i+n; i--) { printf("-"); } } |

Re: Question"Venkat" <venkat_kp@yahoo.com> wrote in message news:<1093531576.117124@sj-nntpcache-3>...
> "Niels Dybdahl" <ndy@fjern.detteesko-graphics.com> wrote in message > news:412def76$0$182$edfadb0f@dtext02.news.tele.dk. .. > > > Can someone crack the other 2 possibilities. > > > > Here is one: > > > > for(i=0;-i<n; i--) > > > > Niels thanks for a quick response, the 2nd possibility > > is for(i=0;i<n;n--) > > we just need the 3rd one. #include <stdio.h> main() { int i, n=20; for(i=0;i+n; i--) { printf("-"); } } |

All times are GMT. The time now is 10:19 PM. |

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.

SEO by vBSEO ©2010, Crawlability, Inc.