# Teaser - 1

 Tweet
39 replies [Last post]
heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
One of the way can be

One of the way can be this..

int main()

{

int i, n = 20;

for (i=0; i<n; n--)

{

cout << "x"<<endl; }

}

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
This is the correct

This is the correct way...

int main()

{

int i,n=20;

for (i=0; i<n; i++)

{

cout<<"x"<<endl;

}

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
answer

1.

int i, n=20;

for(i=0;i<n;n--)

{

cout<<"x"<<endl;

}

After this change we can modify first as:

2.

int i, n=20;

for(i<0;i<n,n--)

{

cout<<"x"<<endl;

}

After 2nd we can again modify it as follows :

3.

int i,n=21;

for(i<0;i<n;n--)

{

cout<<"x"<<endl;

}

All the out put will print * 20 times.....

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hi

But the best way is the same that ADI has posted in his second post....!!!

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
The second solution

The second solution is:...

int main()

{

int i, n = 20;

for (i=0; -i<n; i--)

{

cout << "x"<<endl; }

}

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354

int i, n=20;

for(i=0;-i<n;i--)

{

cout <<"x"<<endl;

}

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
aashiq you have made the

aashiq you have made the changeas at two places... that i think is against the rule... so note that dear..

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hi

int i, n=20;

for(i=20;i<n;i--)

{

cout<<"x"<<endl;

}

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hey

yeah thanks adi.. now i got all three rite i think....

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
Hey

actually adi m modifying one change sequentially in my program that i had posted first so i doon  think thats wrong .. because its not mentioned in the rules...... dat whether  we hav to do it either way or not hence we can do it .. first i consider the given programn then i start making one changes in every program i wrote sequentiaaly in order

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
By changing only ONE

By changing only ONE character in the above code,

UI think this line of rules will clear your doubt...

Your final code..you have written.. will give you infinite loop... so i think it will not work

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hi

oh yees.. okie i got it...

lemme c thru it again....!!

nitesh
Offline
Last seen: 9 years 35 weeks ago
Joined: 2009-03-26
bOt Points: 370

You guys should have posted all your THREE attempts together.

That way you wouldn't have given away the answers for free

@heloitsadi

you  have cracked two way. However the third one is still pending

@aashiqcoolguy

heloitsadi has already pointed out the flaw with your attempt. It was clearly written CHANGING ONLY ONE CHARACTER  , that was enough  information.

as for your correct attempts , they were preceeded by heloitsadi's correct answers. Hope you get the point.

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
Ya trying to get the third

Ya trying to get the third one as well...

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
int

int i,n=20

for(i=0;i<n;-i--)

{

cout<<"x"<<endl;

}

shubham
Offline
Last seen: 7 years 35 weeks ago
Joined: 2009-05-28
bOt Points: 134
Reply!

Well try!!

But still not the correct answer..

u need to brush up your operator precedence rule knowledge.

Best Of luck:-)

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
heu

nobody is interested in it apart frm me n adi............ m still into the third sol.. mking me crazy but i wil find out

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
I couldn't get the third

I couldn't get the third  one... I doubt is it possible... Botskool if the third solution is possible.... ANY HINT!!!!

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
i don

I dont think its impossible bt ya dificult though ... if it is said there r three.. the main thing is we r missing sumthing... if two chnges r allowe then there r numerous ways...... please post som [email protected]

bOtskOOl
Offline
Last seen: 10 years 2 weeks ago
Joined: 2009-02-21
bOt Points: 3500
HINT

third way is very much possible

it just requires thinking out of the box.

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hey

Hey I really not sure .. whether my concepts are getting wrong but still m posting it may b wrong... but will not give up .. !! I don know whether this is rite or wrong...

int i, n=20;

for (i=0;i<n+i--)

{

cout<<"x"<<endl;

}

nitesh
Offline
Last seen: 9 years 35 weeks ago
Joined: 2009-03-26
bOt Points: 370
You are rite Its

You are rite

Its incorrect

But nyways keep up the spirit.

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
is it correct

int i,n=20;

for(i=0;-n<i<n;i--)

{

cout<<"x"<<endl;

}

nitesh
Offline
Last seen: 9 years 35 weeks ago
Joined: 2009-03-26
bOt Points: 370
did you count how many

did you count how many characters you have changed ??

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hint

Yar koi toh hint de do .. itna dimag laga diya....  ??

bOtskOOl
Offline
Last seen: 10 years 2 weeks ago
Joined: 2009-02-21
bOt Points: 3500
HINT

Test conditions may not always require relational operators

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
I got it botskool... THaks

I got it botskool... THaks for that hint...

1st Solution:

int main()

{

int i, n = 20;

for (i=0; i<n; n--)

{

cout << "x"<<endl; }

}

2nd Solution:

int main()

{

int i, n = 20;

for (i=0; -i<n; i--)

{

cout << "x"<<endl; }

}

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hey doubt

adi can u just explain me how the thrd sol works.. ??? please.. !!

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
sorry still not right...

sorry still not right...

nitesh
Offline
Last seen: 9 years 35 weeks ago
Joined: 2009-03-26
bOt Points: 370
Incorrect

@heloitsadi

Still not there

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hmm ..

I think u did it with .... I++ rite ??

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
should the last one be...

int i , n=20;

for(i=0;i+n;i--)

{

cout<<"x"<<endl;

}

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
Here is the #rd one:... int

Here is the 3rd one:...

int main()

{

int i, n = 20;

for (i=0; i+n; i--)

{

cout << "x"<<endl;

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
Finally i cracked it... now

Finally i cracked it... now everything is right... Thanks botskool for you hint... Please crosscheck all my solutions...

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
adi .. i posted it olready

HEY I posted it olreaady the thord solution... thanx botskool for ur hint...!!

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
just a slight mistake in

just a slight mistake in previous chance..i used i-n and i++, now corrected it... asihq you caught my trick.. nice catch

heloitsadi
Offline
Last seen: 10 years 33 weeks ago
Joined: 2009-03-15
bOt Points: 1321
hey bro i wrote it in

hey bro i wrote it in chat..admit it dear... don't take advantage... first two solutions are also posted by me...

Whatever learning should be the basic motto.... THanks

aashiqcoolguy21
Offline
Last seen: 9 years 48 weeks ago
Joined: 2009-05-31
bOt Points: 3354
hmm.

never mind adi.. u deserve the win... !!!

ne ways.. what actually matters is tym n advantage ... some tymes....

bOtskOOl
Offline
Last seen: 10 years 2 weeks ago
Joined: 2009-02-21
bOt Points: 3500
heloitsadi wins

heloitsadi wins

Teaser Closed