Solved

please explain the for loop

Posted on 2006-07-17
4
309 Views
Last Modified: 2010-04-15
Can anyone please explain the below code...

#include<stdio.h>
main()
{ int a,b,c;
int count = 1;

for (b=c=10;a="- FIGURE?, UMKC,XYZHello Folks,\ TFy!QJu ROo TNn(ROo)SLq SLq ULo+\ UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\ NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\ HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\ T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\ Hq!WFs XDt!" [b+++21]; )

for(; a-- > 64 ; ) putchar ( ++c=='Z' ? c = c/ 9:33^b&1);
return 0; }
0
Comment
Question by:Suhas .
  • 2
4 Comments
 
LVL 8

Expert Comment

by:manish_regmi
ID: 17121184
hmm, a similar q was posted about a year ago (i forgot the link). That draw the picture using characters. I hope this does something similar.

ok, it  draws i pic just uses '!'. Some creative programmer might have created it. :)

regards
Manish Regmi

0
 
LVL 8

Assisted Solution

by:manish_regmi
manish_regmi earned 50 total points
ID: 17121207
ok its here. Looks like same algo

http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_20711665.html


regards
Manish regmi
0
 
LVL 22

Accepted Solution

by:
grg99 earned 75 total points
ID: 17121248
Simple:     :)


#include<stdio.h>   //you figure this one out
main()   // we have a program
{ int a,b,c;   /with three int variables
int count = 1;   // and "count"

for (
    b=c=10;   //intilize b and c to 10

a="- FIGURE?, UMKC,XYZHello Folks,\ TFy!QJu ROo TNn(ROo)SLq SLq ULo+\ UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\ NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\ HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\ T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\ Hq!WFs XDt!" [b+++21];  // set a to the 31st chartacter of that long quoted string, quit looping when we fall off the end
 )

for(;
 a-- > 64 ;   /  'A' is 64, so count down the letter we got above til we get down to 'A'

 ) putchar (    // print whatever the expression evaluates to.
    ++c=='Z'    // remember we set c to 10?  count it up til it hits 'Z' (90)
    ? c = c/ 9    // when it hits 90, reset it back to 10   (90/9)  and print 10 (LINE FEED)
     : 33^b&1     //   otherwise (before 90)  b anded with 1 gives alternatiing 0 and 1) xor with 33 and
                        // it will  print either 32 (space) or (33) asterisk.);
return 0; }


// so basically it prints alternating runs of spaces and asterisks, with a line feed every 80 characters.

0
 
LVL 11

Expert Comment

by:cup
ID: 17125962
Possibly based on the stuff from the obfuscated C competition.  If you wish to  to have a look at more complex examples.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now