Solved

please explain the for loop

Posted on 2006-07-17
4
320 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 .
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

756 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