
|
|

General Forum: Information Technology | C fans... Happy Thinking !!! | |
| There iz a site called
"http://www.funducode.com/...Hope some of U might be knowin thiz site....
Hope U guyz know Yashwant Kanetkar, the famous author of several C 'n' C++ Programmin bookz...The site waz developed 'n' iz being maintaned by him.....
Kinda verry verry good site on thiz planet earth. U can even subscribe for weekly programmin update....Njjoyyy.....
Posted by: UK At: 24, Sep 2002 12:32:32 PM IST I can think of only two sols with single change.
* Changing i to -i at cond eval.
for ( i = 0; -i ( n; i--)
printf ("-") ;
* Changing "(" sign to "+".
for ( i = 0; i + n; i--)
printf("-") ;
There are three solution in case of making two changes.
* for ( i = 0; i ) -n; i--)
printf("-") ;
* for ( i = 0; i != -n; i--)
printf("-") ;
* for ( i = 0; i / n + 1; i--)
printf("-") ;
Good puzzle Ravi...
Posted by: Sreedhar G At: 24, Sep 2002 1:30:48 AM IST Hi,
Here's a good puzzle for C fans... Others, pls ignore.
Given the following lines of code:
int i, n = 20;
for (i = 0; i ( n; i--)
printf ("-");
Now you know that this will result in infinite loop.
Show 3 ways in which , by changing 1 and only 1 character, it will print the character "-" 20 times.
Note that changing i-- to i++ is not valid. Also you cant add or delete any character. You just have to alter 1 and only 1 character.
Happy Thinking !!!
Posted by: Mr. Ravi Kumar Guntuku At: 23, Sep 2002 7:39:40 PM IST
|
|
|
 |
Advertisements |
|
 |
 |
Advertisements |
|