Solved

please explain the for loop

Posted on 2006-07-17
4
315 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C: GetDiskFreeSpaceEx() for default drive 14 107
Finding a good hash function 4 122
Digital Output does not have continuity to ground? 3 90
What is atomic operation? 6 58
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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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 and use switch statements in the C programming language.

813 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