Love

November 28th, 2010
No Gravatar

In reality, there is no permanent love. As time passess your feelings to someones changes. As much as possible never give 100% love because if she/he doesn’t love you will not hurt too much. Like this quote - “A sad thing in life is that sometimes you meet someone who means a lot to you only to find out in the end that it was never bound to be and you just have to let go.”

We must learn to love, to be hurt and let go…

Share/Save/Bookmark

Turbo C Sample Input Validation

October 19th, 2010
No Gravatar

Input validation in turbo c is one of the problem by many programmers. If the input is not properly filtered by the program, it can ruined the entire program. Here is my sample program.

#include <math.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

void main_menu(void);
void sub_menu(void);
void area_of_circle(void);
void area_of_triangle(void);
void area_of_square(void);
void input_validation(char tempo[6], int mem_pt);
void save_pt(int memo);

void save_pt(int memo)
{
switch (memo)
{
case 1: area_of_circle();
case 2: area_of_triangle();
case 3: area_of_square();
}
}

void input_validation(char tempo[6], int mem_pt)
{
int deci_ptr=0,i=0;
while (tempo[i]!=’\n’)
{
if (tempo[i]==’.'&&deci_ptr==1)
{
printf(”\nToo much decimal point!!!”);
getch();
save_pt(mem_pt);
}
if (tempo[i]<’0′||tempo[i]>’9′)
{
printf(”\nPlease enter a number!!!”);
getch();
save_pt(mem_pt);
}
if (strlen(tempo)==1&&tempo[i]==’.')
{
printf(”\nPlease enter a number!!!”);
getch();
save_pt(mem_pt);
}
if (tempo[i]==’.') deci_ptr=1;

i++;
}
}

void main_menu(void)
{
char c;
clrscr();
printf(”Main Menu:\n\n”);
printf(”[a] Area of Circle\n”);
printf(”[b] Area of Triangle\n”);
printf(”[c] Area of Square\n”);
printf(”Select: “);
c=getche();
switch (c)
{
case ‘a’: area_of_circle();
case ‘A’: area_of_circle();
case ‘b’: area_of_triangle();
case ‘B’: area_of_triangle();
case ‘c’: area_of_square();
case ‘C’: area_of_square();
default: printf(”\nPlease select from the menu!”);getch();main_menu();
}
}

void sub_menu(void)
{
char c;
printf(”\n\nGoto Main Menu: [Y/N]: “);
c=getche();
switch (c)
{
case ‘y’: main_menu();
case ‘Y’: main_menu();
case ‘n’: printf(”\nGood bye!!!”);getch();exit(0);
case ‘N’: printf(”\nGood bye!!!”);getch();exit(0);
default: printf(”\nError!!!”);getch();sub_menu();
}
}

void area_of_circle(void)
{
char number[6];
float area,radius;
clrscr();
printf(”Area of Circle:\n\n”);
printf(”Enter the radius of circle: “);
fgets(number,6,stdin);
input_validation(number,1);
radius=atof(number);
printf(”\nThe area of the circle is %f”,radius*radius*M_PI);
getch();
sub_menu();
}

void area_of_triangle(void)
{
char number[6];
float area,base,height;
clrscr();
printf(”Area of Triangle:\n\n”);
printf(”Enter base: “);
fgets(number,6,stdin);
input_validation(number,2);
base=atof(number);
printf(”\nEnter height: “);
fgets(number,6,stdin);
input_validation(number,2);
height=atof(number);
printf(”\nThe area of the triangle is %f”,base*height/2);
getch();
sub_menu();
}

void area_of_square(void)
{
char number[6];
float area,height;
clrscr();
printf(”Area of the Square:\n\n”);
printf(”Enter the height: “);
fgets(number,6,stdin);
input_validation(number,3);
height=atof(number);
printf(”\nThe area of the square is %f”,height*height);
getch();
sub_menu();
}

void main(void)
{
main_menu();
}

Happy programming. :-)

Share/Save/Bookmark

Marina Bay

October 9th, 2010
No Gravatar

Another tourist spot destination in Singapore is the Marina Bay. You will see here famous spot which is the Merlion Park. Here are some of my photos.

Share/Save/Bookmark

Trip to Sentosa

October 9th, 2010
No Gravatar

One of the tourist spot in Singapore is Sentosa. There are lot of places to see in Sentosa like Universal Studios, Merlion Walk and the beaches. Here are my photos.

Share/Save/Bookmark

Julian Beever at VivoCity

October 9th, 2010
No Gravatar

On my way to Sentosa, I just pass by to VivoCity and lucky to see Julian Beever doing his art work. Here are some of my photos.

Share/Save/Bookmark

Life in Singapore

September 6th, 2010
No Gravatar

These are my recent photos here in Singapore.

At the changi airport.

inside the mrt

inside the MRT

Suntec City Mall

at Suntec City Mall

Causeway Point Woodlands

Causeway Point Woodlands

Lucky Plaza

Lucky Plaza

Share/Save/Bookmark

First week studying autocad

April 10th, 2010
No Gravatar

I learned a lot in studying autocad 2010 at Microcad. I learned how to create lines, circles, rectangle, polygons and many more. Positioning, editing and scaling the objects, I wish I can learn more about 3D objects and pass the final examination. ^_^

Share/Save/Bookmark

The Rubik Cube

March 26th, 2010
No Gravatar

The Rubik Cube is one of my favorite toy. Invented by ErnÅ‘ Rubik of Budapest, Hungary. Rubik cube comes in 2×2, 3×3, 4×4, 5×5, 6×6 and 7×7. For more information about this cube visit rubiks.

Solving the Rubik cube (3×3) is quite hard for first timer. To solve the cube easily you must first start to the bottom layer, then middle layer and lastly to the top layer. Check the youcandothecube for some information in solving the Rubik’s cube.

Share/Save/Bookmark

Happy Holidays

December 26th, 2009
No Gravatar

Merry Christmas and a Happy New Year!!!

Share/Save/Bookmark

Heroes of Newerth

August 6th, 2009
No Gravatar

Try this new cool game made by S2 games. Dota look alike game. Nice graphics and cool characters.

To get your beta keys. Go to www.fileplay.net

Watch this video - http://www.youtube.com/watch?v=uaCQBv7IreE

Share/Save/Bookmark


Nalanlee is Digg proof thanks to caching by WP Super Cache!