Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

please explain the for loop

Posted on 2006-07-17
4
Medium Priority
?
328 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 200 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 300 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Suggested Courses

886 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