Pages

Thursday, April 15, 2010

My name is $%#@^%$

Not really sure who asked me, but recently at a dinner where most of the invitees didn’t know each other we were asked to introduce ourselves without using the sentence “My name is …”. So here is my (Fictional Version).
It is said that eating An Apple a Day keeps the Doctor away, OR you can throw it at him, it would keep him away too. I am more like the second scenario, Not the ‘Apple thrower’ but the Doctor.
I have been really very lucky in life, And life has thrown a lot of Apples at me but instead of running away like the doctor i added all the Apples to my orchard and made it more beautiful, and since I'm the only Adam of my garden (OK, this sentence is mainly targeting the females.) collected all those Apples and made a successful business out of it. it gives me that small measure of peace that we all try to seek but few of us ever find.
I really like to relate my self more to the Doctor in this, as it is said of ‘Healing hands’ or the ‘Hands of a Healer’ in many ancient legends. The one who can heal shall be healed.
So call me what you will,
but the ending of this i shall still
be the force of your will
‘coz my name is $%#@^%$.

Wednesday, April 14, 2010

What’s with a Semicolon; !!!

Engineering programming labs in VTU, are pretty much the same boring sessions where you copy something from the notice board and type it on the computer, ask the lab assistant how to compile the program and just copy down the output and leave the lab. But here is something for those who want to spice up their programs this is a technique i learnt in high school. How to write C/C++ programs without a semicolon?”.

A little Background:

This technique is very vastly discussed all over the internet in the past few years, but when i learnt this the internet in India was still in its infancy and our only source was the Library and if you were lucky enough a programming geek (usually 5~6 yrs older than you) with uncles in USA.

The Trick:

Conditional statements. !!
That's all.
A normal output statement in c would be
printf(“Hello”);
And in C++ it would be
cout<<”Hello”;
A normal Condition in C/C++ would look like this,
if(Test condition){
Stmnt1;
Stmnt2;
}
The interesting part is the Test condition, just replace it with your output statement that's all.

Example:

#include <stdio.h>

void main(){
printf("test");
}


see it working here http://codepad.org/QZnYTR5o


#include <stdio.h>

void main(){
if(printf("test")){}
}


see it working here http://codepad.org/cKnS605C


As you can see both the outputs are same.


The second program has no semicolons, the same can be achieved using Loops but i will leave it to you to figure it out. :-)