Friday, July 27, 2012


Tower Of Hanoi Program. 

#include

void towers(int,char,char,char);

void towers(int n,char frompeg,char topeg,char auxpeg)
{
    // If only 1 disk, make the move and return
    if(n==1)
    {
        printf("\nMove disk 1 from peg %c to peg %c",frompeg,topeg);
        return;
    }
    // Move top n-1 disks from A to B, using C as auxiliary
    towers(n-1,frompeg,auxpeg,topeg);
    // Move remaining disks from A to C
    printf("\nMove disk %d from peg %c to peg %c",n,frompeg,topeg);
    // Move n-1 disks from B to C using A as auxiliary
    towers(n-1,auxpeg,topeg,frompeg);
}
main()
{
    int n;
    printf("Enter the number of disks : ");
    scanf("%d",&n);
    printf("The Tower of Hanoi involves the moves :\n\n");
    towers(n,'A','C','B');
    return 0;
}

Thursday, July 26, 2012

Program to validate the given IPv4 address:)


#include
#include

int isValidIp (char *str)
{
    int segs = 0;
    int chcnt = 0;
    int accum = 0;

    if (str == NULL)
        return 0;
    while (*str != '\0')
    {
        if (*str == '.')
        {
            if (chcnt == 0)
                return 0;
            if (++segs == 4)
                return 0;
            chcnt = accum = 0;
            str++;
            continue;
        }
        if ((*str < '0') || (*str > '9'))
            return 0;
        if ((accum = accum * 10 + *str - '0') > 255)
            return 0;
        chcnt++;
        str++;

    }
    if (segs != 3)
        return 0;
    if (chcnt == 0)
        return 0;
    return 1;
}

int main()
{
    char strg[18];
    while(1)
    {
        printf("\n Enter IP : ");
        scanf("%s", strg);
        isValidIp(strg) ? printf("\n Valid IP") : printf("\n Invalid IP");
    }
    return 0;
}

Sunday, April 26, 2009

Do u know?

Politics s de only profession whr nt even a single suicide s registered.
Interesting na?
Think y!!

Wednesday, September 5, 2007

Heaven was here

Imagine 10 yrs now.........


U r now a good spouse....


A parent of 2....



Getting a chance 2 visit the college was ur dream since u've left...U came.... U c the long pathways of fate lying lonely ahead... with bundles of scattered leaves fallen frm the tree of love.... the tree of hope... The trees under which once friendship was made...love was made.....



Lonely classrooms with a gentle breeze from the windows of change.... fills in the thoughts about the past... Pictures of ur friends flash thru ur mind like photographs...
The moments u spared 2gether...the sadness that they r all gone.... their voices haunt ur thoughts...Only memories would be there in place of ur friends... in the darkness of ur memories... in the darkness of ur thoughts...ur mind will slowly whisper............




HEAVEN WAS HERE....!
ONCE...!!!!