Sunday 30 March 2014

PERSONAL DIARY MANAGEMENT USING C PROGRAM

#include<stdio.h>

#include<stdlib.h>

#include<conio.h>

#include<string.h>


int password();

void addrecord();

void viewrecord();

void editrecord();

void editpassword();

void deleterecord();


struct record

{

    char time[6];

    char name[30];

    char place[25];

    char duration[10];

    char note[500];

} ;


int main()

{

    int ch;

    printf("\n\n\t***********************************\n");

    printf("\t*PASSWORD PROTECTED PERSONAL DIARY*\n");

    printf("\t***********************************");


   while(1)


        {

                printf("\n\n\t\tMAIN MENU:");

                printf("\n\n\tADD RECORD\t[1]");

                printf("\n\tVIEW RECORD\t[2]");

                printf("\n\tEDIT RECORD\t[3]");

                printf("\n\tDELETE RECORD\t[4]");

                printf("\n\tEDIT PASSWORD\t[5]");

                printf("\n\tEXIT\t\t[6]");

                printf("\n\n\tENTER YOUR CHOICE:");

                scanf("%d",&ch);


            switch(ch)

                    {

                            case 1:

                            addrecord();

                            break;


                            case 2:

                            viewrecord();

                            break;


                            case 3:

                            editrecord();

                            break;


                            case 4:

                            deleterecord();

                            break;


                            case 5:

                            editpassword();

                            break;


                            case 6:

                            printf("\n\n\t\tTHANK YOU FOR USING THE SOFTWARE BY:\n\n\tBIJAY PURI\n\n\tBHANU POUDEL\n\n\tNRIPASH AYER...");

                            getch();

                            exit(0);


                            default:

                            printf("\nYOU ENTERED WRONG CHOICE..");

                            printf("\nPRESS ANY KEY TO TRY AGAIN");

                            getch();

                            break;

                    }

                system("cls");

        }

            return 0;

}

void addrecord( )

{

                system("cls");

                FILE *fp ;

                char another = 'Y' ,time[10];

                struct record e ;

                char filename[15];

                int choice;

                printf("\n\n\t\t***************************\n");

                printf("\t\t* WELCOME TO THE ADD MENU *");

                printf("\n\t\t***************************\n\n");

                printf("\n\n\tENTER DATE OF YOUR RECORD:[yyyy-mm-dd]:");

                fflush(stdin);

                gets(filename);

                fp = fopen (filename, "ab+" ) ;

                if ( fp == NULL )

                {

                fp=fopen(filename,"wb+");

                if(fp==NULL)

                {

                    printf("\nSYSTEM ERROR...");

                    printf("\nPRESS ANY KEY TO EXIT");

                    getch();

                    return ;

                }

                }



                while ( another == 'Y'|| another=='y' )

                {

                    choice=0;

                    fflush(stdin);

                printf ( "\n\tENTER TIME:[hh:mm]:");

                scanf("%s",time);

                rewind(fp);

                while(fread(&e,sizeof(e),1,fp)==1)

                {

                    if(strcmp(e.time,time)==0)

                    {

                        printf("\n\tTHE RECORD ALREADY EXISTS.\n");

                        choice=1;

                    }

                }

                    if(choice==0)

                    {

                        strcpy(e.time,time);

                        printf("\tENTER NAME:");

                        fflush(stdin);

                        gets(e.name);

                        fflush(stdin);

                        printf("\tENTER PLACE:");

                        gets(e.place);

                        fflush(stdin);

                        printf("\tENTER DURATION:");

                        gets(e.duration);

                        fflush(stdin);

                        printf("\tNOTE:");

                        gets(e.note);

                        fwrite ( &e, sizeof ( e ), 1, fp ) ;

                        printf("\nYOUR RECORD IS ADDED...\n");

                    }

                        printf ( "\n\tADD ANOTHER RECORD...(Y/N) " ) ;

                        fflush ( stdin ) ;

                        another = getchar( ) ;

                }


                fclose ( fp ) ;

                printf("\n\n\tPRESS ANY KEY TO EXIT...");

                getch();

    }


void viewrecord( )

{

        FILE *fpte ;

        system("cls");

        struct record customer ;

        char time[6],choice,filename[14];

        int ch;

        printf("\n\n\t\t*******************************\n");

        printf("\t\t* HERE IS THE VIEWING MENU *");

        printf("\n\t\t*******************************\n\n");

        choice=password();

        if(choice!=0)

            {

                return ;

            }

        do

            {

                    printf("\n\tENTER THE DATE OF RECORD TO BE VIEWED:[yyyy-mm-dd]:");

                    fflush(stdin);

                    gets(filename);


                    fpte = fopen ( filename, "rb" ) ;

                    if ( fpte == NULL )

                            {

                                puts ( "\nTHE RECORD DOES NOT EXIST...\n" ) ;

                                printf("PRESS ANY KEY TO EXIT...");

                                getch();

                                return ;

                            }

                            system("cls");

                printf("\n\tHOW WOULD YOU LIKE TO VIEW:\n");

                printf("\n\t1.WHOLE RECORD OF THE DAY.");

                printf("\n\t2.RECORD OF FIX TIME.");

                printf("\n\t\tENTER YOUR CHOICE:");

                scanf("%d",&ch);

                switch(ch)

                {

                    case 1:

                            printf("\nTHE WHOLE RECORD FOR %s IS:",filename);

                         while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 )

                         {

                            printf("\n");

                            printf("\nTIME: %s",customer.time);

                            printf("\nMEETING WITH: %s",customer.name);

                            printf("\nMEETING AT: %s",customer.place);

                            printf("\nDURATION: %s",customer.duration);

                            printf("\nNOTE: %s",customer.note);

                            printf("\n");

                         }

                         break;


                    case 2:

                            fflush(stdin);

                            printf("\nENTER TIME:[hh:mm]:");

                            gets(time);

                            while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 )


                            {

                                if(strcmp(customer.time,time)==0)

                                {

                                    printf("\nYOUR RECORD IS:");

                                    printf("\nTIME: %s",customer.time);

                                    printf("\nMEETING WITH: %s",customer.name);

                                    printf("\nMEETING AT: %s",customer.place);

                                    printf("\nDUARATION: %s",customer.duration);

                                    printf("\nNOTE: %s",customer.note);

                                }

                            }

                            break;


                    default: printf("\nYOU TYPED SOMETHING ELSE...\n");

                             break;

                }


               printf("\n\nWOULD YOU LIKE TO CONTINUE VIEWING...(Y/N):");

               fflush(stdin);

            scanf("%c",&choice);

        }while(choice=='Y'||choice=='y');

            fclose ( fpte ) ;

            return ;

}

void editrecord()

{

        system("cls");

        FILE *fpte ;

        struct record customer ;

        char time[6],choice,filename[14];

        int num,count=0;

        printf("\n\n\t\t*******************************\n");

        printf("\t\t* WELCOME TO THE EDITING MENU *");

        printf("\n\t\t*******************************\n\n");

        choice=password();

        if(choice!=0)

            {

                return ;

            }

        do

            {

                    printf("\n\tENTER THE DATE OF RECORD TO BE EDITED:[yyyy-mm-dd]:");

                    fflush(stdin);

                    gets(filename);

                    printf("\n\tENTER TIME:[hh:mm]:");

                    gets(time);

                    fpte = fopen ( filename, "rb+" ) ;

                    if ( fpte == NULL )

                            {

                                printf( "\nRECORD DOES NOT EXISTS:" ) ;

                                printf("\nPRESS ANY KEY TO GO BACK");

                                getch();

                                return;

                            }

                    while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 )

                    {

                        if(strcmp(customer.time,time)==0)

                        {

                            printf("\nYOUR OLD RECORD WAS AS:");

                            printf("\nTIME: %s",customer.time);

                            printf("\nMEETING WITH: %s",customer.name);

                            printf("\nMEETING AT: %s",customer.place);

                            printf("\nDURATION: %s",customer.duration);

                            printf("\nNOTE: %s",customer.note);


                            printf("\n\n\t\tWHAT WOULD YOU LIKE TO EDIT..");

                                printf("\n1.TIME.");

                                printf("\n2.MEETING PERSON.");

                                printf("\n3.MEETING PLACE.");

                                printf("\n4.DURATION.");

                                printf("\n5.NOTE.");

                                printf("\n6.WHOLE RECORD.");

                                printf("\n7.GO BACK TO MAIN MENU.");

                                do

                                {

                                        printf("\n\tENTER YOUR CHOICE:");

                                        fflush(stdin);

                                        scanf("%d",&num);

                                        fflush(stdin);

                                        switch(num)

                                        {

                                            case 1: printf("\nENTER THE NEW DATA:");

                                                    printf("\nNEW TIME:[hh:mm]:");

                                                    gets(customer.time);

                                                    break;


                                            case 2: printf("\nENTER THE NEW DATA:");

                                                    printf("\nNEW MEETING PERSON:");

                                                    gets(customer.name);

                                                    break;


                                            case 3: printf("\nENTER THE NEW DATA:");

                                                    printf("\nNEW MEETING PLACE:");

                                                    gets(customer.place);

                                                    break;


                                            case 4: printf("\nENTER THE NEW DATA:");

                                                    printf("\nDURATION:");

                                                    gets(customer.duration);

                                                    break;


                                            case 5: printf("ENTER THE NEW DATA:");

                                                    printf("\nNOTE:");

                                                    gets(customer.note);

                                                    break;


                                            case 6:  printf("\nENTER THE NEW DATA:");

                                                     printf("\nNEW TIME:[hh:mm]:");

                                                     gets(customer.time);

                                                     printf("\nNEW MEETING PERSON:");

                                                     gets(customer.name);

                                                     printf("\nNEW MEETING PLACE:");

                                                     gets(customer.place);

                                                     printf("\nDURATION:");

                                                     gets(customer.duration);

                                                     printf("\nNOTE:");

                                                     gets(customer.note);

                                                     break;


                                            case 7: printf("\nPRESS ANY KEY TO GO BACK...\n");

                                                    getch();

                                                    return ;

                                                    break;


                                            default: printf("\nYOU TYPED SOMETHING ELSE...TRY AGAIN\n");

                                                     break;

                                        }


                                }while(num<1||num>8);

                            fseek(fpte,-sizeof(customer),SEEK_CUR);

                            fwrite(&customer,sizeof(customer),1,fpte);

                            fseek(fpte,-sizeof(customer),SEEK_CUR);

                            fread(&customer,sizeof(customer),1,fpte);

                            choice=5;

                            break;

                        }

                    }

                    if(choice==5)

                    {

                    system("cls");

                    printf("\n\t\tEDITING COMPLETED...\n");

                    printf("--------------------\n");

                    printf("THE NEW RECORD IS:\n");

                    printf("--------------------\n");

                    printf("\nTIME: %s",customer.time);

                    printf("\nMEETING WITH: %s",customer.name);

                    printf("\nMEETING AT: %s",customer.place);

                    printf("\nDURATION: %s",customer.duration);

                    printf("\nNOTE: %s",customer.note);

                    fclose(fpte);

                    printf("\n\n\tWOULD YOU LIKE TO EDIT ANOTHER RECORD.(Y/N)");

                    scanf("%c",&choice);

                    count++;

                    }

                    else

                    {

                        printf("\nTHE RECORD DOES NOT EXIST::\n");

                        printf("\nWOULD YOU LIKE TO TRY AGAIN...(Y/N)");

                        scanf("%c",&choice);

                    }


            }while(choice=='Y'||choice=='y');

            fclose ( fpte ) ;


            if(count==1)

            printf("\n%d FILE IS EDITED...\n",count);

            else if(count>1)

            printf("\n%d FILES ARE EDITED..\n",count);

            else

            printf("\nNO FILES EDITED...\n");

            printf("\tPRESS ENTER TO EXIT EDITING MENU.");

            getch();

}

int password()

{

        char pass[15]={0},check[15]={0},ch;

        FILE *fpp;

        int i=0,j;

        printf("::FOR SECURITY PURPOSE::");

        printf("::ONLY THREE TRIALS ARE ALLOWED::");

        for(j=0;j<3;j++)

        {

                        i=0;

                        printf("\n\n\tENTER THE PASSWORD:");

                        pass[0]=getch();

                        while(pass[i]!='\r')

                        {

                            if(pass[i]=='\b')

                            {

                                i--;

                                printf("\b");

                                printf(" ");

                                printf("\b");

                                pass[i]=getch();

                            }

                            else

                            {

                                printf("*");

                                i++;

                                pass[i]=getch();

                            }

                        }

                        pass[i]='\0';

                        fpp=fopen("SE","r");

                        if (fpp==NULL)

                        {

                            printf("\nERROR WITH THE SYSTEM FILE...[FILE MISSING]\n");

                            getch();

                            return 1;

                        }

                        else

                        i=0;

                        while(1)

                        {

                            ch=fgetc(fpp);

                            if(ch==EOF)

                            {

                                check[i]='\0';

                                break;

                            }

                            check[i]=ch-5;

                            i++;

                        }

                        if(strcmp(pass,check)==0)

                        {

                            printf("\n\n\tACCESS GRANTED...\n");

                            return 0;

                        }

                        else

                        {

                            printf("\n\n\tWRONG PASSWORD..\n\n\tACCESS DENIED...\n");

                        }

        }

        printf("\n\n\t::YOU ENTERED WRONG PASSWORD::YOU ARE NOT ALLOWED TO ACCESS ANY FILE::\n\n\tPRESS ANY KEY TO GO BACK...");

        getch();

        return 1;

}

void editpassword()

{

    system("cls");

    printf("\n");

    char pass[15]={0},confirm[15]={0},ch;

    int choice,i,check;

    FILE *fp;

    fp=fopen("SE","rb");

    if(fp==NULL)

    {

        fp=fopen("SE","wb");

        if(fp==NULL)

        {

            printf("SYSTEM ERROR...");

            getch();

            return ;

        }

        fclose(fp);

        printf("\nSYSTEM RESTORED...\nYOUR PASSWORD IS 'ENTER'\n PRESS ENTER TO CHANGE PASSWORD\n\n");

        getch();

    }

        fclose(fp);

        check=password();

    if(check==1)

    {

        return ;

    }

    do

    {

        if(check==0)

                    {

                        i=0;

                        choice=0;

                        printf("\n\n\tENTER THE NEW PASSWORD:");

                        fflush(stdin);

                        pass[0]=getch();

                        while(pass[i]!='\r')

                        {

                            if(pass[i]=='\b')

                            {

                                i--;

                                printf("\b");

                                printf(" ");

                                printf("\b");

                                pass[i]=getch();

                            }

                            else

                            {

                                printf("*");

                                i++;

                                pass[i]=getch();

                            }

                        }

                        pass[i]='\0';

                        i=0;

                        printf("\n\tCONFIRM PASSWORD:");

                        confirm[0]=getch();

                        while(confirm[i]!='\r')

                        {

                            if(confirm[i]=='\b')

                            {

                                i--;

                                printf("\b");

                                printf(" ");

                                printf("\b");

                                confirm[i]=getch();

                            }

                            else

                            {

                                printf("*");

                                i++;

                                confirm[i]=getch();

                            }

                        }

                        confirm[i]='\0';

                        if(strcmp(pass,confirm)==0)

                        {

                            fp=fopen("SE","wb");

                            if(fp==NULL)

                            {

                                printf("\n\t\tSYSTEM ERROR");

                                getch();

                                return ;

                            }

                            i=0;

                            while(pass[i]!='\0')

                            {

                                ch=pass[i];

                                putc(ch+5,fp);

                                i++;

                            }

                            putc(EOF,fp);

                            fclose(fp);

                        }

                        else

                        {

                            printf("\n\tTHE NEW PASSWORD DOES NOT MATCH.");

                            choice=1;


                        }


                    }

}while(choice==1);


    printf("\n\n\tPASSWORD CHANGED...\n\n\tPRESS ANY KEY TO GO BACK...");

    getch();

}


void deleterecord( )

{

                system("cls");

                FILE *fp,*fptr ;

                struct record file ;

                char filename[15],another = 'Y' ,time[10];;

                int choice,check;

                printf("\n\n\t\t*************************\n");

                printf("\t\t* WELCOME TO DELETE MENU*");

                printf("\n\t\t*************************\n\n");

                check = password();

                    if(check==1)

                    {

                        return ;

                    }


                while ( another == 'Y' )

                {

                printf("\n\n\tHOW WOULD YOU LIKE TO DELETE.");

                printf("\n\n\t#DELETE WHOLE RECORD\t\t\t[1]");

                printf("\n\t#DELETE A PARTICULAR RECORD BY TIME\t[2]");


                do

                {

                        printf("\n\t\tENTER YOU CHOICE:");

                        scanf("%d",&choice);


                    switch(choice)

                        {

                            case 1:

                            printf("\n\tENTER THE DATE OF RECORD TO BE DELETED:[yyyy-mm-dd]:");

                            fflush(stdin);

                            gets(filename);

                            fp = fopen (filename, "wb" ) ;

                            if ( fp == NULL )

                            {

                                printf("\nTHE FILE DOES NOT EXISTS");

                                printf("\nPRESS ANY KEY TO GO BACK.");

                                getch();

                                return ;

                            }

                            fclose(fp);

                            remove(filename);

                            printf("\nDELETED SUCCESFULLY...");

                            break;


                            case 2:

                            printf("\n\tENTER THE DATE OF RECORD:[yyyy-mm-dd]:");

                            fflush(stdin);

                            gets(filename);

                            fp = fopen (filename, "rb" ) ;

                            if ( fp == NULL )

                            {

                                printf("\nTHE FILE DOES NOT EXISTS");

                                printf("\nPRESS ANY KEY TO GO BACK.");

                                getch();

                                return ;

                            }

                            fptr=fopen("temp","wb");

                            if(fptr==NULL)

                            {

                                printf("\nSYSTEM ERROR");

                                printf("\nPRESS ANY KEY TO GO BACK");

                                getch();

                                return ;

                            }

                            printf("\n\tENTER THE TIME OF RECORD TO BE DELETED:[hh:mm]:");

                            fflush(stdin);

                            gets(time);

                            while(fread(&file,sizeof(file),1,fp)==1)

                            {

                                if(strcmp(file.time,time)!=0)

                                fwrite(&file,sizeof(file),1,fptr);

                            }


                            fclose(fp);

                            fclose(fptr);

                            remove(filename);

                            rename("temp",filename);

                            printf("\nDELETED SUCCESFULLY...");

                            break;


                    default:

                            printf("\n\tYOU ENTERED WRONG CHOICE");

                            break;

                    }

                }while(choice<1||choice>2);



                    printf("\n\tDO YOU LIKE TO DELETE ANOTHER RECORD.(Y/N):");

                    fflush(stdin);

                    scanf("%c",&another);

                }

                printf("\n\n\tPRESS ANY KEY TO EXIT...");

                getch();

}

Tuesday 25 March 2014

ANIMATRONICS



ABSTRACT

        Animatronics is a cross between animation and electronics. Basically, an animatronic is a mechanized puppet. It may be preprogrammed or remotely controlled. An abbreviated term originally coined by Walt Disney as "Audio-Animatronics" (used to describe his mechanized characters), can actually be seen in various forms as far back as Leonardo-Da-Vinci's Automata Lion, (theoretically built to present lillies to the King of France during one of his Visits),and has now developed as a career which may require combined talent in Mechanical Engineering , Sculpting / Casting, Control Technologies, Electrical / Electronic, Airbrushing, Radio-Control.
        Long before digital effects appeared, animatronics were making cinematic history. The scare generated by the Great White coming out of the water in "Jaws" and  the tender otherworldliness of "E.T." were its outcomes. The Jurassic Park series combined digital effects with animatronics.
        It is possible for us to build our own animatronics by making use of ready-made animatronic kits provided by companies such as Mister Computers where no programming skills are required.Only a knowledge of Windows is required.
                                               

Air powered cars


ABSTRACT
Have you been to the gas station this week? Considering that we live in a very mobile society, it's probably safe to assume that you have. While pumping gas, you've undoubtedly noticed how much the price of gas has soared in recent years. Gasoline which has been the main source of fuel for the history of cars, is becoming more and more expensive and impractical (especially from an environmental standpoint). These factors are leading car manufacturers to develop cars fueled by alternative energies. Two hybrid cars took to the road in 2000, and in three or four years fuel-cell-powered cars will roll onto the world's highways.

This seminar is to explain the working of air powered cars. These type of cars will run on compressed air instead of gasoline .The car is powered by a two cylinder compressed air engine.

The air powered car is also called as a low pollution or zero pollution cars. Since the car runs on compressed air it is environmentally friendly.



Friday 14 March 2014

AMAZING SNAKE GAME ! CHECK IT NOW ITSELF

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>
#include<time.h>
#include<ctype.h>
#include <time.h>
#include <windows.h>
#include <process.h>

#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77

int length;
int bend_no;
int len;
char key;
void record();
void load();
int life;
void Delay(long double);
void Move();
void Food();
int Score();
void Print();
void gotoxy(int x, int y);
void GotoXY(int x,int y);
void Bend();
void Boarder();
void Down();
void Left();
void Up();
void Right();
void ExitGame();
int Scoreonly();

struct coordinate{
    int x;
    int y;
    int direction;
};

typedef struct coordinate coordinate;

coordinate head, bend[500],food,body[30];

int main()
{

    char key;

    Print();

    system("cls");

    load();

    length=5;

    head.x=25;

    head.y=20;

    head.direction=RIGHT;

    Boarder();

    Food(); //to generate food coordinates initially

    life=3; //number of extra lives

    bend[0]=head;

    Move();   //initialing initial bend coordinate

    return 0;

}

void Move()
{
    int a,i;

    do{

        Food();
        fflush(stdin);

        len=0;

        for(i=0;i<30;i++)

        {

            body[i].x=0;

            body[i].y=0;

            if(i==length)

            break;

        }

        Delay(length);

        Boarder();

        if(head.direction==RIGHT)

            Right();

        else if(head.direction==LEFT)

            Left();

        else if(head.direction==DOWN)

            Down();

        else if(head.direction==UP)

            Up();

        ExitGame();

    }while(!kbhit());

    a=getch();

    if(a==27)

    {

        system("cls");

        exit(0);

    }
    key=getch();

    if((key==RIGHT&&head.direction!=LEFT&&head.direction!=RIGHT)||(key==LEFT&&head.direction!=RIGHT&&head.direction!=LEFT)||(key==UP&&head.direction!=DOWN&&head.direction!=UP)||(key==DOWN&&head.direction!=UP&&head.direction!=DOWN))

    {

        bend_no++;

        bend[bend_no]=head;

        head.direction=key;

        if(key==UP)

            head.y--;

        if(key==DOWN)

            head.y++;

        if(key==RIGHT)

            head.x++;

        if(key==LEFT)

            head.x--;

        Move();

    }

    else if(key==27)

    {

        system("cls");

        exit(0);

    }

    else

    {

        printf("\a");

        Move();

    }
}

void gotoxy(int x, int y)
{

 COORD coord;

 coord.X = x;

 coord.Y = y;

 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);

}
void GotoXY(int x, int y)
{
    HANDLE a;
    COORD b;
    fflush(stdout);
    b.X = x;
    b.Y = y;
    a = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(a,b);
 }
void load(){
    int row,col,r,c,q;
    gotoxy(36,14);
    printf("loading...");
    gotoxy(30,15);
    for(r=1;r<=20;r++){
    for(q=0;q<=100000000;q++);//to display the character slowly
    printf("%c",177);}
    getch();
}
void Down()
{
    int i;
    for(i=0;i<=(head.y-bend[bend_no].y)&&len<length;i++)
    {
        GotoXY(head.x,head.y-i);
        {
            if(len==0)
                printf("v");
            else
                printf("*");
        }
        body[len].x=head.x;
        body[len].y=head.y-i;
        len++;
    }
    Bend();
    if(!kbhit())
        head.y++;
}
void Delay(long double k)
{
    Score();
    long double i;
    for(i=0;i<=(10000000);i++);
}
void ExitGame()
{
    int i,check=0;
    for(i=4;i<length;i++)   //starts with 4 because it needs minimum 4 element to touch its own body
    {
        if(body[0].x==body[i].x&&body[0].y==body[i].y)
        {
            check++;    //check's value increases as the coordinates of head is equal to any other body coordinate
        }
        if(i==length||check!=0)
            break;
    }
    if(head.x<=10||head.x>=70||head.y<=10||head.y>=30||check!=0)
    {
        life--;
        if(life>=0)
        {
            head.x=25;
            head.y=20;
            bend_no=0;
            head.direction=RIGHT;
            Move();
        }
        else
        {
            system("cls");
            printf("All lives completed\nBetter Luck Next Time!!!\nPress any key to quit the game\n");
            record();
            exit(0);
        }
    }
}
void Food()
{
    if(head.x==food.x&&head.y==food.y)
    {
        length++;
        time_t a;
        a=time(0);
        srand(a);
        food.x=rand()%70;
        if(food.x<=10)
            food.x+=11;
        food.y=rand()%30;
        if(food.y<=10)

            food.y+=11;
    }
    else if(food.x==0)/*to create food for the first time coz global variable are initialized with 0*/
    {
        food.x=rand()%70;
        if(food.x<=10)
            food.x+=11;
        food.y=rand()%30;
        if(food.y<=10)
            food.y+=11;
    }
}
void Left()
{
    int i;
    for(i=0;i<=(bend[bend_no].x-head.x)&&len<length;i++)
    {
        GotoXY((head.x+i),head.y);
       {
                if(len==0)
                    printf("<");
                else
                    printf("*");
        }
        body[len].x=head.x+i;
        body[len].y=head.y;
        len++;
    }
    Bend();
    if(!kbhit())
        head.x--;

}
void Right()
{
    int i;
    for(i=0;i<=(head.x-bend[bend_no].x)&&len<length;i++)
    {
        //GotoXY((head.x-i),head.y);
        body[len].x=head.x-i;
        body[len].y=head.y;
        GotoXY(body[len].x,body[len].y);
        {
            if(len==0)
                printf(">");
            else
                printf("*");
        }
        /*body[len].x=head.x-i;
        body[len].y=head.y;*/
        len++;
    }
    Bend();
    if(!kbhit())
        head.x++;
}
void Bend()
{
    int i,j,diff;
    for(i=bend_no;i>=0&&len<length;i--)
    {
            if(bend[i].x==bend[i-1].x)
            {
                diff=bend[i].y-bend[i-1].y;
                if(diff<0)
                    for(j=1;j<=(-diff);j++)
                    {
                        body[len].x=bend[i].x;
                        body[len].y=bend[i].y+j;
                        GotoXY(body[len].x,body[len].y);
                        printf("*");
                        len++;
                        if(len==length)
                            break;
                    }
                else if(diff>0)
                    for(j=1;j<=diff;j++)
                    {
                        /*GotoXY(bend[i].x,(bend[i].y-j));
                        printf("*");*/
                        body[len].x=bend[i].x;
                        body[len].y=bend[i].y-j;
                        GotoXY(body[len].x,body[len].y);
                        printf("*");
                        len++;
                        if(len==length)
                            break;
                    }
            }
        else if(bend[i].y==bend[i-1].y)
        {
            diff=bend[i].x-bend[i-1].x;
            if(diff<0)
                for(j=1;j<=(-diff)&&len<length;j++)
                {
                    /*GotoXY((bend[i].x+j),bend[i].y);
                    printf("*");*/
                    body[len].x=bend[i].x+j;
                    body[len].y=bend[i].y;
                    GotoXY(body[len].x,body[len].y);
                        printf("*");
                   len++;
                   if(len==length)
                           break;
               }
           else if(diff>0)
               for(j=1;j<=diff&&len<length;j++)
               {
                   /*GotoXY((bend[i].x-j),bend[i].y);
                   printf("*");*/
                   body[len].x=bend[i].x-j;
                   body[len].y=bend[i].y;
                   GotoXY(body[len].x,body[len].y);
                       printf("*");
                   len++;
                   if(len==length)
                       break;
               }
       }
   }
}
void Boarder()
{
   system("cls");
   int i;
   GotoXY(food.x,food.y);   /*displaying food*/
       printf("F");
   for(i=10;i<71;i++)
   {
       GotoXY(i,10);
           printf("!");
       GotoXY(i,30);
           printf("!");
   }
   for(i=10;i<31;i++)
   {
       GotoXY(10,i);
           printf("!");
       GotoXY(70,i);
       printf("!");
   }
}
void Print()
{
   //GotoXY(10,12);
   printf("\tWelcome to the mini Snake game.(press any key to continue)\n");
  getch();
   system("cls");
   printf("\tGame instructions:\n");
   printf("\n-> Use arrow keys to move the snake.\n\n-> You will be provided foods at the several coordinates of the screen which you have to eat. Everytime you eat a food the length of the snake will be increased by 1 element and thus the score.\n\n-> Here you are provided with three lives. Your life will decrease as you hit the wall or snake's body.\n\n-> YOu can pause the game in its middle by pressing any key. To continue the paused game press any other key once again\n\n-> If you want to exit press esc. \n");
   printf("\n\nPress any key to play game...");
   if(getch()==27)
   exit(0);
}
void record(){
   char plname[20],nplname[20],cha,c;
   int i,j,px;
   FILE *info;
   info=fopen("record.txt","a+");
   getch();
   system("cls");
   printf("Enter your name\n");
   scanf("%[^\n]",plname);
   //************************
   for(j=0;plname[j]!='\0';j++){ //to convert the first letter after space to capital
   nplname[0]=toupper(plname[0]);
   if(plname[j-1]==' '){
   nplname[j]=toupper(plname[j]);
   nplname[j-1]=plname[j-1];}
   else nplname[j]=plname[j];
   }
   nplname[j]='\0';
   //*****************************
   //sdfprintf(info,"\t\t\tPlayers List\n");
   fprintf(info,"Player Name :%s\n",nplname);
    //for date and time

   time_t mytime;
  mytime = time(NULL);
  fprintf(info,"Played Date:%s",ctime(&mytime));
     //**************************
     fprintf(info,"Score:%d\n",px=Scoreonly());//call score to display score
     //fprintf(info,"\nLevel:%d\n",10);//call level to display level
   for(i=0;i<=50;i++)
   fprintf(info,"%c",'_');
   fprintf(info,"\n");
   fclose(info);
   printf("wanna see past records press 'y'\n");
   cha=getch();
   system("cls");
   if(cha=='y'){
   info=fopen("record.txt","r");
   do{
       putchar(c=getc(info));
       }while(c!=EOF);}
     fclose(info);
}
int Score()
{
   int score;
   GotoXY(20,8);
   score=length-5;
   printf("SCORE : %d",(length-5));
   score=length-5;
   GotoXY(50,8);
   printf("Life : %d",life);
   return score;
}
int Scoreonly()
{
int score=Score();
system("cls");
return score;
}
void Up()
{
   int i;
   for(i=0;i<=(bend[bend_no].y-head.y)&&len<length;i++)
   {
       GotoXY(head.x,head.y+i);
       {
           if(len==0)
               printf("^");
           else
               printf("*");
       }
       body[len].x=head.x;
       body[len].y=head.y+i;
       len++;
   }
   Bend();
   if(!kbhit())
       head.y--;
}

EIGHT QUEENS PROBLEM


#include<stdio.h>
#include<conio.h>
#include<math.h>
int a[30],count=0;
int place(int pos)
{
 int i;
 for(i=1;i<pos;i++)
 {
  if((a[i]==a[pos])||((abs(a[i]-a[pos])==abs(i-pos))))
   return 0;
 }
 return 1;
}
void print_sol(int n)
{
 int i,j;
 count++;
 printf("\n\nSolution #%d:\n",count);
 for(i=1;i<=n;i++)
 {
  for(j=1;j<=n;j++)
  {
   if(a[i]==j)
    printf("Q\t");
   else
    printf("*\t");
  }
  printf("\n");
 }
}
void queen(int n)
{
 int k=1;
 a[k]=0;
 while(k!=0)
 {
  a[k]=a[k]+1;
  while((a[k]<=n)&&!place(k))
   a[k]++;
  if(a[k]<=n)
  {
   if(k==n)
    print_sol(n);
   else
   {
    k++;
    a[k]=0;
   }
  }
  else
   k--;
 }
}
void main()
{
 int i,n;
 printf("Enter the number of Queens\n");
 scanf("%d",&n);
 queen(n);
 printf("\nTotal solutions=%d",count);
 getch();
}