Facebook

Animated Donut : C program


Hi,

Just like my previous post in which India's map was generated using an obfuscated C code, here an animated donut will be generated, again using C code.

Note : This is not my work. All credit to original author (link at the bottom).


This donut program has two versions.

Version 1:

(To avoid any error due to formating and special characters, I am including screen-shots of the code. Actual code can be found on the Original Author's page. Copy the code and save it in a file donut.c and compile using the command given below.

 


Execute this Code using the command -
gcc -o donut donut.c -lm
Ignore any warnings. Now run it using command -
./donut

Output should look like below image:







Version 2:

This is much more impressive.




Save and compile this code again using the same command and run it.

Credit - Andy Sloane 
Follow this link to know the mathematics behind this animation.

Generate India's map using C-Program


This is one of smallest and most efficient code ever written. This code is just 16 lines long and will generate the India's map.


#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;
}


Output is going to look like this -




See the code at work here - http://codepad.org/XGDEnKxj

Now next question is how this code generates this map? Here is the answer -
http://stackoverflow.com/questions/3533348/how-does-this-code-generate-the-map-of-india

Enjoy.


Why 42?




So why 42? What is the significance of number 42?  Why I chose the name as newbie42 and not just newbie?
Because domain name newbie was not available. Simple. But why 42? why not 99 or 100 or any random number?


Project Android device screen on your laptop


Whenever you need to demonstrate something to everyone present in the classroom or meeting room, you connect the laptop with projector and project the laptop screen. This is simple, you either use RGB cable or HDMI port.
What if you have developed some Android application and want to demonstrate it to a large audience. There is no HDMI port in Android device.