Saturday, September 13, 2008

Programming Puzzle - 1

int main()
{
   int i,n=20;
   for(i=0;i<n;i--)
      printf("*");
   return 0;
}

Change/add only one character in the above program and print '*' exactly 20 times..

5 comments:

Unknown said...

Change n in place of i i.e(n--)

mbvreddy said...

Thats correct, but there are 3 more ways...

Venkata Ranga Reddy said...

n=-20; will also work

Venkata Ranga Reddy said...

condition "-i<n"; will work

mbvreddy said...

one more solution is there.