Saturday, 7 January 2017

Hangman (beta)


#include<iostream>
#include<fstream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<ctype.h>
using namespace std;

int play();

void writef();
void readf();

class player

{
char name[20];
int score;
public:
player()
{
strcpy(name,"New Player");
score=0;
}
void updatescore();
void getname();
void stat();
int retscore();
};

player cur,obj;


void readf()

{
fstream f;
f.open("score.dat",ios::in|ios::binary);
if(f)
{
f.read((char*)&obj,sizeof(obj));
}
f.close();
}

void writef()

{
fstream f;
f.open("score.dat",ios::out|ios::binary|ios::trunc);
f.write((char*)& cur,sizeof(cur));
f.close();
}

int player::retscore()

{
return score;
}

void player::updatescore()

{
++score;
}

void player::stat()

{
cout<<"\n\nName:"<<name;
cout<<"\nScore:"<<score<<endl;
}

void player::getname()

{
cout<<"\n\t\t\tEnter name:";
gets(name);
cin.getline(name,20);
}

int play()

{
    cur.getname();
fstream file;
file.open("data.txt",ios::in);
char word[10],dash[10],c='!';
int temp;
while(1)
{
int m=rand() % 10 + 1,trial;
file.seekp (0);
for(int i=0;i<m;++i)
file>>word;
m=strlen(word);
strcpy(dash,word);
for(int i=0;i<m;++i)
dash[i]='-';
trial=m+3;
while(trial!=1)
{
            //system("cls");
temp=0;
for(int i=0;i<m;++i)
{

if(word[i]==c)

{
dash[i]=c;
                    temp=1;
}


}

if(strcmp(word,dash)==0)
{
cur.updatescore();
cout<<"The Name Was : "<<word<<endl;
cout<<"\nCongrags You've Won\nCurrent Score";
cur.stat();
c='!';
char ch;
cout<<"\nPlay again(y/n):";
cin>>ch;
if(ch=='y'||ch=='Y')
{
goto end;
}
else
{
trial=-1;
break;
}

}


--trial;

            if (temp)
++trial;
cout<<"\nGuess the name\n"<<trial<<" lives left\n\t\t\t\t";
puts(dash);
c='!';
cout<<"\nEnter a character:";
cin>>c;
c=toupper(c);

}



if(cur.retscore()>obj.retscore())

{ writef();
file.close();
}

if(trial==-1)

{
return 0;
}
if(strcmp(word,dash))
{
cout<<"\nBetter luck next time:)\n";
getch();
file.close();
return 0;
}

end:

    ;
}


}


void highscore()

{
system("cls");
readf();
cout<<"\n\t\t##################High Score##################";
obj.stat();
cout<<"\n";
}
int main()
{ int op;
readf();

while(1)

{
        op=-1;
system("cls");
cout<<"1.Play\n2.View Highscore\n3.About\n4.Exit\nEnter choice:";
cin>>op;
if(op==1)
play();
else if(op==2)
{ highscore();
getch();
}
else if(op==3);

else if (op==4)

exit(0);
else
{
            cout<<"\nInvalid Choice";
getch();
        }

}


}


download

Wednesday, 16 September 2015

Fake Home Work(do not try this at school)



















#include<iostream>
#include<windows.h>
#include<string.h>
using namespace std;
int main()
{   cout<<"calmchicken";
    char ge[500];
    cout<<"\n\t\t\tEnter your lines(max limit 500):";
    cin.getline(ge,500);
    int x=strlen(ge);
    int xtime=0;
    while(xtime<100)

     {

        cout<<"\n"<<++xtime<<",";
        cout.write(ge,x);
        Sleep(150);
     }
}

C++ Matrix














#include<iostream>
#include<windows.h>
#include<stdlib.h>
int main()
{   int as;
    system("color 02");
    while(1)
    std::cout<<(as=rand());

}



PRINT ASCII AND RESPT. CHARCTER




#include <iostream>
#include<conio.h>
#include<windows.h>
using namespace std;
int main ()
{
    int b=0;
    while(b<1000)
    {
        char am=b++;
        cout<<b<<":\t"<<am<<"\n";
        Sleep(500);
        int b=++b;
    }
}

Friday, 21 August 2015

Shutdown Manager!!



#include<iostream>
#include<conio.h>
#include<windows.h>
#include<iomanip>
using namespace std;
int main()
{
  char cmn,c;
  system("color e");
  cout<<setw(15)<<"l- Log off.\ns- Shutdown the computer.\nr-Full shutdown and restart the computer.\ng- Full shutdown and restart the computer.After the system is rebooted, restart any registered applications.\np-Turn off the local computer with no time-out or warning.\nh- Hibernate the local computer.-:::";
  cin>>cmn;
  switch(cmn)
  {
      case 'l':Sleep(2000);system("shutdown/l");
      break;
      case 's':Sleep(2000);system("shutdown/s");
      cout<<"\na-Abort a system shutdown.-:::";
      cin>>c;

      {
          case 'a':Sleep(2000);system("shutdown/a");cout<<"\nShutdown Canceled";
          break;
      }
      break;
      case 'r':Sleep(2000);system("shutdown/r");
      break;
      case 'g':Sleep(2000);system("shutdown/g");
      break;
      case 'p':Sleep(2000);system("shutdown/p");
      break;
      case 'h':Sleep(2000);system("shutdown/h");
      break;
      default:Sleep(2000);system("color c");cout<<"\n\t\t wrong entry";break;

  }
  getch();
}

Infinite Loop



#include<iostream>
using namespace std;
int main()
{
    while(1)
    cout<<"Da@N%$!*GEr ";

    }

Shutdown Prank




#include<iostream>
#include<windows.h>
using namespace std;
 main()
{
    cout<<"#GE*RGE!#";
    cout<<"\n\t\t\t\t\t\tloading.";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    system("cls");
    cout<<"#GE*RGE!#";
    cout<<"\n\t\t\t\t\t\tloading.";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    system("cls");
    cout<<"#GE*RGE!#";
    cout<<"\n\t\t\t\t\t\tloading.";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    system("cls");
    cout<<"#GE*RGE!#";
    cout<<"\n\t\t\t\t\t\tloading.";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    cout<<".";
    Sleep(0700);
    system("cls");
    cout<<"#GE*RGE!#";
    system("color b");
    cout<<"\n\t\t\t\t\t   Press any key in 1 sec";
    Sleep(1500);
    system("cls");
    cout<<"#GE*RGE!#";
    int a,b=5456;
    system("color 9");
    system("shutdown /s" );
    Sleep(1500);
    cout<<"\n\n\n\n\n\t\t\t\t Enter the password to abort shutdown:";
    system("color e");
    cin>>a;
    system("cls");
    cout<<"#GE*RGE!#";

    if(a==b)
    {   system("color b");
        cout<<"\n\n\n\n\n\n\t\t\t\t  Correct entry! Shutdown aborting in t-6sec";
        Sleep(6000);
        system("cls");
        cout<<"#GE*RGE!#";
        system("shutdown /a");
        Sleep(2000);
        return 0;

    }

    else(a!=b);
    {   system("cls");
        cout<<"#GE*RGE!#";
        Sleep(1000);
        system("color c");
        system("cls");
        cout<<"#GE*RGE!#";
        cout<<"\n\n\t\t\t\t\t    WRONG KEY ENTRY";
        cout<<"\n\n\t\t\t              Hint:Convert 'TV' to HEX";
        Sleep(1500);
        system("cls");
        cout<<"#GE*RGE!#";
        cout<<"\n\n\n\n\t\t\t              Hint:Convert 'TV' to HEX";
        system("color e");
        Sleep(2500);
        system("color d");
        cout<<"\n\t\t\t Enter the password to try again(P.S this is the last chance):";
        cin>>a;

        if(a==b)
    {   system("color b");
        cout<<"\n\t\t\t\t\tCorrect entry! Shutdown aborting in t-3sec.";
        Sleep(3000);
        system("shutdown /a");
        Sleep(5000);
        system("color 02");
        return 0;
    }

    else if(a!=b)
    {
        system("cls");
        cout<<"#GE*RGE!#";
        Sleep(1000);
        system("color c");
        cout<<"\n\n\t\t\t\t\t    WRONG KEY ENTRY";
        Sleep(3000);
        system("color d");
        system("cls");
        cout<<"#GE*RGE!#";
        cout<<"\n\n\n\t\t\t\t\tBYE BYE";

}
}
}