City Of Future: Singapore


The paradigm has shifted, the world is accelerating, the science fiction of yesterday is rapidly becoming the science fiction of right now. How do we continue to learn when information is moving at the speed of light ? There are places that are ahead of the curve, Singapore is building the tools for tomorrow.
The future of the world lies in its urban environments. More than half the world's population live in cities and that number is growing. This rapid influx of people creates possibility but it also creates challenges. How can the cities of today grow and thrive to become the places we want to live in tomorrow. Creating sustainable, manageable human spaces in the world's ever-expanding cities is a challenge facing governments across the globe.

Video Source: National Geographic

Singapore is preparing for the future, planning ahead of time. Along with the rapid urbanization and advanced technological advancements, this city is vibrant, safe and also sustainable for the people now and also for the future.

C Program to solve Tower of Hanoi Problem Using Recursion


This C Program uses recursive function to solve tower of hanoi problem.The tower of hanoi is a mathematical puzzle problem.It is also a great example of recursion.
It consists of three rods, and a number of disks of different sizes.While transferring disk from one rod other, larger disk can't be at the top of smaller disk.
We have to obtain the same stack on the third rod as in the first rod below:
tower of hanoi
Here is the source code of the C Program for solving towers of hanoi problem.It was successfully compiled and run in Dev C++.

Source Code:
#include<stdio.h>
void toh(int,char,char,char);
void main()
{
int n;
printf("Enter no. of disks:\n");
scanf("%d",&n);
printf("The steps to solve toh are:\n");
toh(n,'A','B','C');
}
void toh(int n,char frompeg,char auxpeg,char topeg)
{
if(n==1)
{
printf("Move disk 1 from peg %c to peg %c.",frompeg,topeg);
return;
}
toh(n-1,frompeg,topeg,auxpeg);
printf("\nMove disk %d from peg %c to peg %c.\n",n,frompeg,topeg);
toh(n-1,auxpeg,frompeg,topeg);
}
//www.sparajuli.com.np

C Program to convert Infix To Postfix Expression Using Stack


This is a  short, easy to understand and functional C Program which converts Infix Expression to Postfix Expression.i.e. (a+b)*c/(d-e)+f   To  ab+cde-/*f+.

Source Code:
#include<ctype.h>
#include<stdio.h>
void push(char elem);
int pr(char elem);
char pop();
char infx[50],pofx[50],ch,elem,s[50];
int top=-1;       /* Global declarations */
void main()
{                         /* Main Program */
    int i=0,k=0;
    push('#');
    printf("\nEnter the Infix Expression: ");
    scanf("%s",infx);
    while( (ch=infx[i++]) != '\0')
    {
        if( ch == '(')
push(ch);
        else if(isalnum(ch))
pofx[k++]=ch;
            else if( ch == ')')
                {
                    while( s[top] != '(')
                        pofx[k++]=pop();
                    elem=pop(); /* Remove ( */
                }
                else
                {       /* Operator */
                    while( pr(s[top]) >= pr(ch) )
                        pofx[k++]=pop();
                    push(ch);
                }
    }
    while( s[top] != '#')     /* Pop from stack till empty */
        pofx[k++]=pop();
    pofx[k]='\0';          /* Make pofx as valid string */
    printf("\n\nInfix Expression: %s\nPostfix Expression: %s\n",infx,pofx);
}
void push(char elem)
{                       /* Function for PUSH operation */
    s[++top]=elem;
}

char pop()
{                      /* Function for POP operation */
    return(s[top--]);
}
int pr(char elem)
{                 /* Function for precedence */
    switch(elem)
    {
    case '#': return 0;break;
    case '(': return 1;break;
    case '+': return 2;break;
    case '-': return 2;break;
    case '*': return 3;break;
    case '/': return 4;break;
    }
}
//www.sparajuli.com.np/

This program is successfully compiled and run in Dev C++ and working.If you have any query, ask below in comment section.