C++--tricky one

Status
Not open for further replies.

QwertyManiac

Commander in Chief
Joined
Jul 17, 2005
Messages
6,575
Here are some, and you can continue giving puzzles there:

Lesser known facts in C and Puzzles for C/C++
 
OP
garfield_56

garfield_56

zzzzzzzzzz........
Joined
Nov 25, 2008
Messages
41
now here's another one-----the program code is extremely :eek:elementary, so i'll just remind all d programmers out there, that this is JUST FOR FUN:):D;)!!!


The question goes like this:::


Code:
int i, n = 20; 
for (i=0; i<n; i--) 
{ 
cout << "x" << endl; 
} 
 
/*   by changing only ONE character in the above code, meaning you cannot change 20 to 31, because you will have changed two characters, you can change 20 to 21, because you only changed the 0, do the following: 
find 3 ways to make the above code print x 20 times (by changing only one character). */

See wat i meant,--this is more of a mental ability :!:question, than a programming one.....
 

Sykora

I see right through you.
Joined
Sep 10, 2005
Messages
594
*www.spoj.pl/problems/BCEASY/

Change i-- to n--.
 

Quiz_Master

* Teh Flirt King *
Joined
Dec 31, 2005
Messages
958
1.
int begin()
{


}

2. int decode(a, n, i, m, a, t, e)(){


}

3. decode(a, n, i, m, a, t, e) is replace by main (# are not counted)



4.
int main()
{

}

Yeah, I remember having fun with same code back in 2nd semester! Even my teacher got fused. He said its fault of DevC++ (on which I was running the code) and that I should use TC++ ROFL :p
 

vamsi360

Always confused
Joined
May 10, 2008
Messages
348
hehe teachers donot even teach logics we have to get them by ourselves. I was enough tired with my teachers explanations
 
Status
Not open for further replies.
Top