physics chemistry maths science forums
become expert I help I sign up I login
refer a friend - earn nickels!!   
 advanced
 
Home
Ask & Discuss Questions
Study Material
Experts Zone
Hang Out!

Ask & Discuss Questions with Community & Experts

Moderation Team
 90 chars left    advanced
Ask iit jee aieee pet cbse icse state board community Community Discussion Question: C++......
Forum Index -> Games, Puzzles and Quizzes like the article? email it to a friend.  
Author Message
Selvaganesh_i (273)

Hot goIITian

Olaaa!! Perrrfect answer. 47  [66 rates]

Selvaganesh_i's Avatar

total posts: 135    
offline Offline
Hi friends i thought of creating a post for C and C++ program.....

if you need any program just post a request here and other GOIITans may help ( including ME )....

if you have any program just post em here and get rated by ME ( FOR SURE ) and other members....

to copy a c++ program there is a simple way tat many of us do not know
(i.e) Just go to the place where you have saved it and just right click and 'open with..' any text editter like notepad......

TO compile it also there is a simple way...
Just copy the program from the post and paste it in NOTEPAD and save as
' .cpp ' or '.c' file and then open it using the c++ editter....

I am saying the above 2 methods cauz many of us write the entire program and tat takes a long time.....

PLEASE GIVE YOUR BEST - THANKS....





    
Selvaganesh_i (273)

Hot goIITian

Olaaa!! Perrrfect answer. 47  [66 rates]

Selvaganesh_i's Avatar

total posts: 135    
offline Offline
Here i am gonna start the post with a c program....

Program : to find the factorial.....

Code :

#include<stdio.h>
#include<conio.h>
factorial(int);
void main()
{
    int a,i;
    long int ans;
    clrscr();
    //ans = 1;
    printf("Enter a number : ");
    scanf("%d",&a);
    ans = factorial (a);
    printf("\nThe Factorial of %d = %ld",a,ans);
    getch();
}
  factorial(int x)
{
  int i,a;
  a = 1;
  for (i = 1;i <= x;i++)
    a = a * i;
  //printf("The ans is = %d",a);
  return(a);
}




 this reply: 20 points  (with Olaaa!! Perrrfect answer.   in 4 votes )   [?]
 
You have to be logged on to rate
  
antonyajay21 (493)

Blazing goIITian

Olaaa!! Perrrfect answer. 91  [110 rates]

antonyajay21's Avatar

total posts: 308    
offline Offline
Hey guys,I am posting the project we did as a team of 2 in our school.I struggled very hard to produce this one for nearly a month.Hope it's useful.
This is a periodic table containing the details of only 20 elements......



#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<ctype.h>
#include<process.h>
#include<string.h>
#include<dos.h>
#include<fstream.h>

void element(int,int);

void welcome_screen()
{
clrscr();
for(int x=50;x>=20;x--)
{
delay(160);
gotoxy(x,12);
cputs("  P R O J E C T   ");
gotoxy(x,14);
cputs("  D E V E L O P E D  B Y  :  ");
gotoxy(x,16);
cputs("                  Programmer 1 ");
gotoxy(x, 18);
cputs("                  Programmer 2 ");
}
gotoxy(x,24);
cputs("Press Any Key To Continue....");
getch();
}

int i,j,g;

void frame()
    {
    gotoxy(19,9);
    cout<<"É";
    for(i=20;i<=60;i++)
     {
     gotoxy(i,9);
     cout<<"Í";
     }
    cout<<"»";
    gotoxy(19,16);
    cout<<"È";
    for(i=20;i<=60;i++)
     {
     gotoxy(i,16);
     cout<<"Í";
     }
    cout<<"¼";
    for(i=10;i<=15;i++)
     {
     gotoxy(19,i);
     cout<<"º";
     }
    for(i=10;i<=15;i++)
     {
     gotoxy(61,i);
     cout<<"º";
     }
    gotoxy(5,24);
    cout<<"Press Esc to Exit";
    }

void display()
{
 gotoxy(33,2);
 cout<<"PERIODIC TABLE";
 gotoxy(1,1);
 cout<<"É";
 for(i=2;i<=79;i++)
  {
  gotoxy(i,1);
  cout<<"Í";
  }
 cout<<"»";
 for(i=2;i<=23;i++)
  {
  gotoxy(80,i);
  cout<<"º";
  }
 gotoxy(80,24);
 cout<<"¼";
 for(i=2;i<=11;i++)
  {
  gotoxy(i,24);
  cout<<"Í";
  }
 gotoxy(1,24);
 cout<<"È";
 for(i=2;i<=23;i++)
  {
  gotoxy(1,i);
  cout<<"º";
  }
 gotoxy(12,4);
 cout<<"Ú"<<"Ä"<<"Ä"<<"¿";
 gotoxy(63,4);
 cout<<"Ú"<<"Ä"<<"Ä"<<"¿";
 gotoxy(12,5);cout<<"³";
 gotoxy(15,5);cout<<"³";
 gotoxy(63,5);cout<<"³";
 gotoxy(66,5);cout<<"³";
 gotoxy(12,6);cout<<"Ã"<<"Ä"<<"Ä"<<"´";
 gotoxy(48,6);cout<<"Ú";
 for(i=51;i<=60;i++)
  if(i%3==0)
   {
   gotoxy(i,6);
   cout<<char(194);
   }
 for(i=48;i<=66;i++)
  if(i%3!=0)
   {
   gotoxy(i,6);
   cout<<"Ä";
   }
 gotoxy(63,6);
 cout<<"Å";
 for(i=48;i<=66;i++)
  if(i%3==0)
   {
   gotoxy(i,7);
   cout<<"³";
   }
 gotoxy(12,7);cout<<"³";
 gotoxy(12,8);cout<<"Ã"<<"Ä"<<"Ä"<<"´";
 gotoxy(12,9);cout<<"³";
 gotoxy(15,9);cout<<"³";
 gotoxy(15,6);cout<<"Å"<<"Ä"<<"Ä"<<"¿";
 gotoxy(15,8);cout<<"Å"<<"Ä"<<"Ä"<<"´";
 gotoxy(18,7);cout<<"³";
 gotoxy(18,9);cout<<"³";
 gotoxy(48,8);cout<<"Ã";
 for(i=51;i<=63;i++)
  if(i%3==0)
   {
   gotoxy(i,8);
   cout<<"Å";
   }
 for(i=48;i<=66;i++)
  if(i%3!=0)
   {
   gotoxy(i,8);
   cout<<"Ä";
   }
 for(i=48;i<=66;i++)
  if(i%3==0)
   {
   gotoxy(i,9);
   cout<<"³";
   }
 gotoxy(12,10);
 cout<<"Ã";gotoxy(15,10);
 cout<<"Å";
 for(i=13;i<=66;i++)
  if(i%3!=0)
     {     gotoxy(i,10);
    cout<<"Ä";
      }for(i=18;i<=45;i++)
  if(i%3==0)
     {     gotoxy(i,10);
    cout<<char(194);
      }for(i=46;i<=63;i++)
  if(i%3==0)
     {     gotoxy(i,10);
    cout<<"Å";
      }gotoxy(18,10);
cout<<"Å";
for(i=12;i<=66;i++)
 if(i%3==0)
  for(j=10;j<=16;j++)
   if(j%2!=0)
    {  gotoxy(i,j);
      cout<<"³";
     }for(i=15;i<=63;i++)
 if(i%3==0)
  for(j=12;j<=14;j++)
   if(j%2==0)
    { gotoxy(i,j);
      cout<<"Å";
     }for(i=15;i<=63;i++)
 if(i%3==0)
  for(j=12;j<=14;j++)
   if(j%2==0)
    { gotoxy(i,j);
      cout<<"Å";
     }for(i=12;i<=66;i++)
 if(i%3==0)
  for(j=12;j<=66;j++)
   if(j%2==0)
    { gotoxy(i,j);
      cout<<"Ä";
     }for(i=15;i<=42;i++)
 if(i%3==0)
  {gotoxy(i,16);
    cout<<"Å";
   }for(i=45;i<=63;i++)
 if(i%3==0)
  { gotoxy(i,16);
    cout<<"Á";
   }for(i=12;i<=42;i++)
 if(i%3==0)
  {  gotoxy(i,17);
    cout<<"³";
   } gotoxy(12,18);
cout<<"À";
for(i=12;i<=42;i++)
 if(i%3!=0)
  {  gotoxy(i,18);
   cout<<"Ä";
  }  cout<<"Ù";
for(i=15;i<=40;i++)
 if(i%3==0)
  {  gotoxy(i,18);
   cout<<"Á";
   } for(i=6;i<=16;i++)
 if(i%2==0)
  {   gotoxy(12,i);
   cout<<"Ã";
  } for(i=6;i<=14;i++)
 if(i%2==0)
  { gotoxy(66,i);
   cout<<"´";
   }gotoxy(66,16);
cout<<"Ù";
gotoxy(12,20);
cout<<"Ú";
for(i=13;i<=23;i++)
 {gotoxy(i,20);
   cout<<"Ä";
 }for(i=24;i<=63;i++)
 if(i%3==0)
  {gotoxy(i,20);
   cout<<char(194);
  }for(i=24;i<=66;i++)
 if(i%3!=0)
  { gotoxy(i,20);
   cout<<"Ä";
   cout<<"¿";
    gotoxy(12,21);
cout<<"³";
 }
 for(i=24;i<=66;i++)
{ if(i%3==0)
  { gotoxy(i,21);
  // cout<<char(194);
  cout<<"³";
   }
}
  for(i=24;i<=66;i++)
{ if(i%3==0)
  { gotoxy(i,20);
   cout<<"Ä";
  }cout<<"¿";
  gotoxy(i,21);
cout<<"³";
}
for(i=24;i<=66;i++)
{ if(i%3==0)
  {gotoxy(i,21);
   cout<<"³";
  }gotoxy(i,22);
cout<<"Ã";
}
for(i=13;i<=23;i++)
  { gotoxy(i,22);
   cout<<"Ä";
  }
  for(i=24;i<=63;i++)
{ if(i%3==0)
  { gotoxy(i,22);
   cout<<"Å";
  }
  }
  for(i=24;i<=66;i++)
{ if(i%3!=0)
  {  gotoxy(i,22);
   cout<<"Ä";
  }  cout<<"´";
      gotoxy(12,23);
cout<<"³";}
for(i=24;i<=66;i++)
  if(i%3==0)
   {  gotoxy(i,23);
     cout<<"³";
  }   gotoxy(12,24);
cout<<"À";
for(i=13;i<=23;i++)
  {    gotoxy(i,24);
    cout<<"À";
  }    for(i=24;i<=63;i++)
 if(i%3==0)
   {  gotoxy(i,24);
     cout<<"Á";
   } for(i=24;i<=66;i++)
  if(i%3!=0)
    { gotoxy(i,24);
      cout<<"Ä";
    }cout<<"Ù";
gotoxy(15,25);
cout<<"ARROWS TO SCROLL.ENTER TO SELECT.ESC TO EXIT.";
gotoxy(13,5);
cout<<"H";
gotoxy(13,7);
cout<<"Li";
gotoxy(13,9);
cout<<"Na";
gotoxy(13,11);
cout<<"K";

gotoxy(15,7); cout<<"³";
for (i=13;i<66;i++)
 {
 gotoxy(i,14);cout<<"Ä";
 gotoxy(i,12);cout<<"Ä";
 gotoxy(i,16);cout<<"Ä";
 if(i>42) {gotoxy(i,18);cout<<"  ";}
 if(i%3==0)
  {
  gotoxy(i,14);cout<<"Å";
  gotoxy(i,12);cout<<"Å";
  gotoxy(i,16);cout<<"Å";
  if(i>42) gotoxy(i,16);cout<<"Á";
  }
 }

for (i=23;i<66;i++)
 {
 gotoxy(i,20);cout<<"Ä";
 gotoxy(i,22);cout<<"Ä";
 gotoxy(i-11,24);cout<<"Ä";
 gotoxy(i,24);cout<<"Ä";
 if(i%3==0)
  {
  gotoxy(i,20);cout<<"Â";
  gotoxy(i,22);cout<<"Å";
  gotoxy(i,24);cout<<"Á";
  }
 }
 for (i=23;i<66;i++)
 {
 if(i%3==0)
  if(i>10)
   {
   gotoxy(i,24);
   cout<<"Á";
   }
 }

for(i=67;i<=80;i++) {gotoxy(i,24);cout<<"Í";}
for(i=0;i<=10;i++) {gotoxy(i,25);cout<<" ";}
for(i=19;i<=47;i++) {gotoxy(i,9);cout<<" ";}
for(i=2;i<=5;i++) {gotoxy(61,i);cout<<" ";}

gotoxy(12,22);cout<<"Ã";
gotoxy(66,20);cout<<"¿ ";
gotoxy(12,24);cout<<"ÀÄ";
gotoxy(80,24);cout<<"¼";
gotoxy(59,9);cout<<" ";
gotoxy(56,9);cout<<" ";


gotoxy(13,13);
cout<<"Rb";
gotoxy(13,15);
cout<<"Cs";
gotoxy(13,17);
cout<<"Fr";
gotoxy(16,7);
cout<<"Be";
gotoxy(16,9);
cout<<"Mg";
gotoxy(16,11);
cout<<"Ca";
gotoxy(16,13);
cout<<"Sr";
gotoxy(16,15);
cout<<"Ba";
gotoxy(16,17);
cout<<"Ra";
gotoxy(19,11);
cout<<"Sc";
gotoxy(19,13);
cout<<"Y";
gotoxy(19,15);
cout<<"La";
gotoxy(19,17);
cout<<"Ac";
gotoxy(22,11);
cout<<"Ti";
gotoxy(22,13);
cout<<"Zr";
gotoxy(22,15);
cout<<"Hf";
gotoxy(22,17);
cout<<"Rf";
gotoxy(25,11);
cout<<"V";
gotoxy(25,13);
cout<<"Nb";
gotoxy(25,15);
cout<<"Ta";
gotoxy(25,17);
cout<<"Ha";
gotoxy(28,11);
cout<<"Cr";
gotoxy(28,13);
cout<<"Mo";
gotoxy(28,15);
cout<<"W";
gotoxy(28,17);
cout<<"Un";
gotoxy(31,11);
cout<<"Mn";
gotoxy(31,13);
cout<<"Tc";
gotoxy(31,15);
cout<<"Re";
gotoxy(31,17);
cout<<"Ns";
gotoxy(34,11);
cout<<"Fe";
gotoxy(34,13);
cout<<"Ru";
gotoxy(34,15);
cout<<"Os";
gotoxy(34,17);
cout<<"Hs";
gotoxy(37,11);
cout<<"Co";
gotoxy(37,13);
cout<<"Rh";
gotoxy(37,15);
cout<<"Ir";
gotoxy(37,17);
cout<<"Mt";
gotoxy(40,11);
cout<<"Ni";
gotoxy(40,13);
cout<<"Pd";
gotoxy(40,15);
cout<<"Pt";
gotoxy(40,17);
cout<<"Uu";
gotoxy(43,11);
cout<<"Cu";
gotoxy(43,13);
cout<<"Ag";
gotoxy(43,15);
cout<<"Au";
gotoxy(46,11);
cout<<"Zn";
gotoxy(46,13);
cout<<"Cd";
gotoxy(46,15);
cout<<"Hg";
gotoxy(49,7);
cout<<"B";
gotoxy(49,9);
cout<<"Al";
gotoxy(49,11);
cout<<"Ga";
gotoxy(49,13);
cout<<"In";
gotoxy(49,15);
cout<<"Tl";
gotoxy(52,7);
cout<<"C";
gotoxy(52,9);
cout<<"Si";
gotoxy(52,11);
cout<<"Ge";
gotoxy(52,13);
cout<<"Sn";
gotoxy(52,15);
cout<<"Pb";
gotoxy(55,7);
cout<<"N";
gotoxy(55,9);
cout<<"P";
gotoxy(55,11);
cout<<"As";
gotoxy(55,13);
cout<<"Sb";
gotoxy(55,15);
cout<<"Bi";
gotoxy(58,7);
cout<<"O";
gotoxy(58,9);
cout<<"S";
gotoxy(58,11);
cout<<"Se";
gotoxy(58,13);
cout<<"Te";
gotoxy(58,15);
cout<<"Po";
gotoxy(61,7);
cout<<"F";
gotoxy(61,9);
cout<<"Cl";
gotoxy(61,11);
cout<<"Br";
gotoxy(61,13);
cout<<"I";
gotoxy(61,15);
cout<<"At";
gotoxy(64,5);
cout<<"He";
gotoxy(64,7);
cout<<"Ne";
gotoxy(64,9);
cout<<"Ar";
gotoxy(64,11);
cout<<"Kr";
gotoxy(64,13);
cout<<"Xe";
gotoxy(64,15);
cout<<"Rn";
gotoxy(13,21);
cout<<"Lanthanides";
gotoxy(25,21);
cout<<"Ce";
gotoxy(28,21);
cout<<"Pr";
gotoxy(31,21);
cout<<"Nd";
gotoxy(34,21);
cout<<"Pm";
gotoxy(37,21);
cout<<"Sm";
gotoxy(40,21);
cout<<"Eu";
gotoxy(43,21);
cout<<"Gd";
gotoxy(46,21);
cout<<"Tb";
gotoxy(49,21);
cout<<"Dy";
gotoxy(52,21);
cout<<"Ho";
gotoxy(55,21);
cout<<"Er";
gotoxy(58,21);
cout<<"Tm";
gotoxy(61,21);
cout<<"Yb";
gotoxy(64,21);
cout<<"Lu";
gotoxy(13,23);
cout<<"Actinides";
gotoxy(25,23);
cout<<"Th";
gotoxy(28,23);
cout<<"Pa";
gotoxy(31,23);
cout<<"U";
gotoxy(34,23);
cout<<"Np";
gotoxy(37,23);
cout<<"Pu";
gotoxy(40,23);
cout<<"Am";
gotoxy(43,23);
cout<<"Cm";
gotoxy(46,23);
cout<<"Bk";
gotoxy(49,23);
cout<<"Cf";
gotoxy(52,23);
cout<<"Ea";
gotoxy(55,23);
cout<<"Fm";
gotoxy(58,23);
cout<<"Md";
gotoxy(61,23);
cout<<"No";
gotoxy(64,23);
cout<<"Lr";
gotoxy(2,2);
i=2;j=2;
gotoxy(i,j);

 do
  {
  g=getch();
  if(g==80)
   {
   if(j==23) j=1;
   gotoxy(i,++j);
   }
  else if(g==77)
   {
   if(i==79) i=1;
   gotoxy(++i,j);
   }
  else if(g==75)
   {
   if(i==2) i=80;
   gotoxy(--i,j);
   }
  else if(g==72)
   {
   if(j==2)
   j=24;
   gotoxy(i,--j);
   }
  if(g==13)
   element(i,j);
  }while(g!=27);
}

void main()
 {
 clrscr();
 welcome_screen();
 int gdriver=DETECT,gmode,errorcode;
 initgraph(&gdriver,&gmode,"h: cin");
 errorcode=graphresult();
 if(errorcode!=grOk)
  {
  cout<<grapherrormsg(errorcode)<<endl;
  getch();
  }
 for (int i=0;i<7;i++)
  {
  delay(150);
  clrscr();
  settextstyle(5,0,i);
  outtextxy(110,75,"    WELCOME");
  outtextxy(155,150,"     TO");
  outtextxy(100,225," PERIODIC TABLE");
  }
 settextstyle(8,0,1);
 outtextxy(200,450,"Press Any Key To Continue ...");
 getch();
 closegraph();
 display();
 }

void element(int i,int j)
 {
 if(((i==13)||(i==14))&&(j==5))
     {
     clrscr();
      frame();
      gotoxy(21,10);
      cout<<"Atomic No                :1"<<" ";
      gotoxy(21,11);
      cout<<"Symbol                   :H"<<" ";
      gotoxy(21,12);
      cout<<"Name                     :Hydrogen"<<" ";
      gotoxy(21,13);
      cout<<"Atomic Radius            :0.37"<<" ";
      gotoxy(21,15);
      cout<<"Electronegetivity        :2.20"<<" ";
      gotoxy(30,20);
      cout<<"Press Any Key To Return.....";
     }
    
 else if(((i==64)||(i==65))&&(j==5))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :2"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :He"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Helium"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :1.2"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :24.58"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :------"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==13)||(i==14))&&(j==7))
       {
    clrscr();
    frame();
    gotoxy(21,10);
    cout<<"Atomic No:               :3"<<" ";
    gotoxy(21,11);
    cout<<"Symbol                   :Li"<<" ";
    gotoxy(21,12);
    cout<<"Name                     :Lithium"<<" ";
    gotoxy(21,13);
    cout<<"Atomic Radius            :1.23"<<" ";
    gotoxy(21,15);
    cout<<"Electronegativity        :0.97"<<" ";
    gotoxy(30,20);
    cout<<"Press Any Key To Return......";
    }
    
 else if(((i==16)||(i==17))&&(j==7))
       {
    clrscr();
    frame();
    gotoxy(21,10);
    cout<<"Atomic No:               :4"<<" ";
    gotoxy(21,11);
    cout<<"Symbol                   :Be"<<" ";
    gotoxy(21,12);
    cout<<"Name                     :Berryllium"<<" ";
    gotoxy(21,13);
    cout<<"Atomic Radius            :0.89"<<" ";
    gotoxy(21,15);
    cout<<"Electronegativity        :1.47"<<" ";
    gotoxy(30,20);
    cout<<"Press Any Key To Return......";
    }
    
 else if(((i==49)||(i==50))&&(j==7))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :5"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :B"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Boron"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :0.80"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :8.3"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :2.01"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==52)||(i==53))&&(j==7))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :6"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :C"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Carbon"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :0.77"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :11.26"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :2.50"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==55)||(i==56))&&(j==7))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :7"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :N"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Nitrogen"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :0.74"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :14.54"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :3.07"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }
 
 else if(((i==58)||(i==59))&&(j==7))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :8"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :O"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Oxygen"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :0.74"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :13.61"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :3.50"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==61)||(i==62))&&(j==7))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :9"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :F"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Fluorine"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :0.72"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :17.42"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :4.10"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==64)||(i==65))&&(j==7))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :10"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :Ne"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Neon"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :1.60"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :21.56"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :-"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==13)||(i==14))&&(j==9))
       {
    clrscr();
    frame();
    gotoxy(21,10);
    cout<<"Atomic No:               :11"<<" ";
    gotoxy(21,11);
    cout<<"Symbol                   :Na"<<" ";
    gotoxy(21,12);
    cout<<"Name                     :Sodium"<<" ";
    gotoxy(21,13);
    cout<<"Atomic Radius            :1.57"<<" ";
    gotoxy(21,15);
    cout<<"Electronegativity        :1.01"<<" ";
    gotoxy(30,20);
    cout<<"Press Any Key To Return......";
    }

 else if(((i==16)||(i==17))&&(j==9))
       {
    clrscr();
    frame();
    gotoxy(21,10);
    cout<<"Atomic No:               :12"<<" ";
    gotoxy(21,11);
    cout<<"Symbol                   :Mg"<<" ";
    gotoxy(21,12);
    cout<<"Name                   :Magnesium"<<" ";
    gotoxy(21,13);
    cout<<"Atomic Radius            :1.36"<<" ";
    gotoxy(21,15);
    cout<<"Electonegativity         :1.23"<<" ";
    gotoxy(30,20);
    cout<<"Press Any Key To Return.....   ";
     }

 else if(((i==49)||(i==50))&&(j==9))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :13"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :Al"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Aluminium"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :1.25"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :6.0"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :1.47"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==52)||(i==53))&&(j==9))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :14"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :Si"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Silicon"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :1.17"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :8.15"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :1.74"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==55)||(i==56))&&(j==9))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :15"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :P"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Phosphorus"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :1.10"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :11.0"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :2.06"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==58)||(i==59))&&(j==9))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :16"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :S"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Sulphur"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :1.04"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :10.36"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :2.44"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }



 else  if(((i==61)||(i==62))&&(j==9))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :17"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :Cl"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Chlorine"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :0.99"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :13.0"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :2.83"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }
    


 else if(((i==64)||(i==65))&&(j==9))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No:               :18"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                   :Ar"<<" ";
     gotoxy(21,12);
     cout<<"Name                     :Argon"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius            :1.90"<<" ";
     gotoxy(21,14);
     cout<<"1st Ionisation potential :15.76"<<" ";
     gotoxy(21,15);
     cout<<"Electronegativity        :-"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return......";
    }

 else if(((i==13)||(i==14))&&(j==11))
       {
    clrscr();
    frame();
    gotoxy(21,10);
    cout<<"Atomic No:               :19"<<" ";
    gotoxy(21,11);
    cout<<"Symbol                   :K"<<" ";
    gotoxy(21,12);
    cout<<"Name                     :Potassium"<<" ";
    gotoxy(21,13);
    cout<<"Atomic Radius            :2.03"<<" ";
    gotoxy(21,15);
    cout<<"Electronegativity        :0.91"<<" ";
    gotoxy(30,20);
    cout<<"Press Any Key To Return......";
    }

 else if(((i==16)||(i==17))&&(j==11))
    {
     clrscr();
     frame();
     gotoxy(21,10);
     cout<<"Atomic No               :20"<<" ";
     gotoxy(21,11);
     cout<<"Symbol                  :ca"<<" ";
     gotoxy(21,12);
     cout<<"Name                   :Calcium"<<" ";
     gotoxy(21,13);
     cout<<"Atomic Radius           :1.74"<<" ";
     gotoxy(21,15);
     cout<<"Electonegativity            :1.04"<<" ";
     gotoxy(30,20);
     cout<<"Press Any Key To Return.....   ";
    }

 else if(((i==13)||(i==14))&&(j==13))
       {
    clrscr();
    frame();
    gotoxy(21,10);
    cout<<"Atomic No:               :37"<<" ";
    gotoxy(21,11);
    cout<<"Symbol                   :Rb"<<" ";
    gotoxy(21,12);
    cout<<"Name                     :Rubidium"<<" ";
    gotoxy(21,13);
    cout<<"Atomic Radius            :2.16"<<" ";
    gotoxy(21,15);
    cout<<"Electronegativity        :0.89"<<" ";
    gotoxy(30,20);
    cout<<"Press Any Key To Return......";
    }

 else if(((i==13)||(i==14))&&(j==15))
       {
    clrscr();
    frame();
    gotoxy(21,10);
    cout<<"Atomic No:               :55"<<" ";
    gotoxy(21,11);
    cout<<"Symbol                   :Cs"<<" ";
    gotoxy(21,12);
    cout<<"Name                     :Cesium"<<" ";
    gotoxy(21,13);
    cout<<"Atomic Radius            :2.35"<<" ";
    gotoxy(21,15);
    cout<<"Electronegativity        :0.86"<<" ";
    gotoxy(30,20);
    cout<<"Press Any Key To Return......";
    }

 else if(((i==13)||(i==14))&&(j==17))
       {
    clrscr();
    frame();
    gotoxy(21,10);
    cout<<"Atomic No:               :87"<<" ";
    gotoxy(21,11);
    cout<<"Symbol                   :Fr"<<" ";
    gotoxy(21,12);
    cout<<"Name                     :Francium"<<" ";
    gotoxy(21,13);
    cout<<"Atomic Radius            :-"<<" ";
    gotoxy(21,15);
    cout<<"Electronegativity        :0.86"<<" ";
    gotoxy(30,20);
    cout<<"Press Any Key To Return......";
    }

 else if(((i==64)||(i==65))&&(j==23))
      {
       clrscr();
       frame();
       gotoxy(21,10);
       cout<<"Atomic No.              :103"<<" ";
       gotoxy(21,11);
       cout<<"Symbol                  :Lr"<<" ";
       gotoxy(21,12);
       cout<<"Name                    :Lawencium"<<" ";
       gotoxy(21,13);
       cout<<"Atomic Radius           :---"<<" ";
       gotoxy(21,14);
       cout<<"1st Ionisation Potential:---"<<" ";
       gotoxy(21,15);
       cout<<"Electonegativity        :1.2"<<" ";
       gotoxy(30,20);
       cout<<"Press Any Key To Return.....";
      }
char key;
key=getch();
if(key==27) exit(0);
else display();
}

Be not afraid of growing slowly.
Be afraid only of standing still.

 this reply: 20 points  (with Olaaa!! Perrrfect answer.   in 4 votes )   [?]
 
You have to be logged on to rate
  
Aatish (2303)

Blazing goIITian

Olaaa!! Perrrfect answer. 413  [532 rates]

Aatish's Avatar

total posts: 1102    
offline Offline
   
TIC TAC TOE GAME.......


    #include<iostream.h>
    #include<conio.h>
    #include<stdio.h>

    void main()
    {
    begin:
    clrscr();
    void showgame(char,char,char,char,char,char,char,char,char);
    int choicex,choicey,flag=0,counter=1,finalchoice;
    char a1,a2,a3,a4,a5,a6,a7,a8,a9,ch,pl1[20],pl2[20];
    a1=' ';
    a2=' ';
    a3=' ';
    a4=' ';
    a5=' ';
    a6=' ';
    a7=' ';
    a8=' ';
    a9=' ';
    cout<<" WELCOME TO TIC-TAC-TOE THE OBJECTIVE OF THE GAME IS TO MAKE YOUR SYMBOL (EITHER 'X' OR 'O' TO TYPE IN A ROW EITHER VERTICALLY OR HORIZONTALLY OR DIAGONALLY AND ALSO TO PREVENT YOUR  OPPONENT FROM DOING SO SO I WISH BOTH THE PLAYERS BEST OF LUCK!!!";
    cin.get(ch);
    clrscr();


    cout<<"PLAYER1 ENTER YOUR NAME  :";

    cin.getline(pl1,20);

    cout<<" PLAYER2 ENTER YOUR NAME  :";

    cin.getline(pl2,20);
    clrscr();
cout<<"    HELLO "<<pl1<<" & "<<pl2;
    cin.get(ch);
    clrscr();



    rematch:
    counter=1;
    clrscr();
    a1=' ';
    a2=' ';
    a3=' ';
    a4=' ';
    a5=' ';
    a6=' ';
    a7=' ';
    a8=' ';
    a9=' ';


    do
    {
    xagain:
    clrscr();
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
   
    cout<<" "<<pl1<<"  PLEASE ENTER YOUR MOVE";
   
    cin>>choicex;
    switch (choicex)
    {
    case 11:
    clrscr();
    if(a1!='Y')
    {
    counter++;
    a1='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a1=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE PRESS ENTER TO RE-ENTER YOUR MOVE";
    cin.get(ch);

    goto xagain;
    }
    break;

    case 12:
    clrscr();
    if(a2!='Y')
    { counter++;
    a2='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a2=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto xagain;
    }
    break;

    case 13:
    clrscr();
    if(a3!='Y')
    { counter++;
    a3='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a3=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto xagain;
    }
    break;

    case 21:
    clrscr();
    if(a4!='Y')
    { counter++;
    a4='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a4=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto xagain;
    }
    break;
    case 22:
    clrscr();
    if(a5!='Y')
    { counter++;
    a5='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a5=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto xagain;
    }
    break;

    case 23:
    clrscr();
    if(a6!='Y')
    { counter++;
    a6='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a6=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto xagain;
    }
    break;

    case 31:
    clrscr();
    if(a7!='Y')
    { counter++;
    a7='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a7=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto xagain;
    }
    break;

     case 32:
    clrscr();
    if(a8!='Y')
    { counter++;
    a8='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a8=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto xagain;
    }
    break;

    case 33:
    clrscr();
    if(a9!='Y')
    { counter++;
    a9='X';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }

    else if(a9=='Y')
    {
    cout<<" SORRY "<<pl2<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto xagain;
    }
    break;

    default:
    cout<<"SORRY ILLEGAL MOVE";
    goto xagain;
    }


    if(  (a1=='X'&&a2=='X'&&a3=='X')  || (a4=='X' && a5=='X' && a6=='X')  ||  ( a7=='X' && a8=='X' && a9=='X') || (a1=='X'&&a4=='X'&&a7=='X')  || (a2=='X'&& a5=='X' && a8=='X') || (a3=='X' && a6=='X' && a9=='X') || (a1=='X' && a5=='X' && a9=='X') ||  (a3=='X'&& a5=='X' && a7=='X')  )
    {
   
    cout<<pl1<<"  WINS!!!";
    cin.get(ch);

    flag++;
    cin.get(ch);
   
    cout<<" THANK YOU FOR PLAYING TIC-TAC-TOE";
    cout<<" PRESS 1 FOR RE-MATCH BETWEEN THE SAME PLAYERS";
    cout<<" PRESS 2 FOR NEW GAME";
    cout<<" PRESS 3 TO QUIT THE GAME";
    cin>>finalchoice;
    if(finalchoice==1)
    goto rematch;
    else if (finalchoice==2)
    goto begin;
    else if(finalchoice==3)
    goto finish;
    else

    break;
    }

    yagain:
    clrscr();
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    cout<<" "<<pl2<<"  PLEASE ENTER YOUR MOVE";
   
    cin>>choicey;
    switch(choicey)
    {
    case 11:
    clrscr();
    if (a1!='X')
    { counter++;
    a1='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a1=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;

    case 12:
    clrscr();
    if (a2!='X')
    { counter++;
    a2='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a2=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;

    case 13:
    clrscr();
    if (a3!='X')
    { counter++;
    a3='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a3=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;

    case 21:
    clrscr();
    if (a4!='X')
    { counter++;
    a4='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a4=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;
    case 22:
    clrscr();
    if (a5!='X')
    { counter++;
    a5='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a5=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;

    case 23:
    clrscr();
    if (a6!='X')
    { counter++;
    a6='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }

    else if(a6=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;

    case 31:
    clrscr();
    if (a7!='X')
    { counter++;
    a7='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a7=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;

     case 32:
    clrscr();
    if (a8!='X')
    { counter++;
    a8='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a8=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;

    case 33:
    clrscr();
    if (a9!='X')
    { counter++;
    a9='Y';
    showgame(a1,a2,a3,a4,a5,a6,a7,a8,a9);
    }
    else if(a9=='X')
    {
    cout<<" SORRY "<<pl1<<"  HAS ALREADY MADE THE MOVE HERE";
    cin.get(ch);
    goto yagain;
    }
    break;

    default:
    cout<<"SORRY ILLEGAL MOVE";
    goto yagain;
    }

    if(  (a1=='Y'&&a2=='Y'&&a3=='Y')  || (a4=='Y' && a5=='Y' && a6=='Y')  ||  ( a7=='Y' && a8=='Y' && a9=='Y') || (a1=='Y'&&a4=='Y'&&a7=='Y')  || (a2=='Y'&& a5=='Y' && a8=='Y') || (a3=='Y' && a6=='Y' && a9=='Y') || (a1=='Y' && a5=='Y' && a9=='Y') ||  (a3=='Y'&& a5=='Y' && a7=='Y')  )
    {
   
    cout<<pl2<<"  WINS!!!";
    cin.get(ch);
   
    flag++;
    cin.get(ch);
    cout<<" THANK YOU FOR PLAYING TIC-TAC-TOE";
    cout<<" PRESS 1 FOR RE-MATCH BETWEEN THE SAME PLAYERS";
    cout<<" PRESS 2 FOR NEW GAME";
    cout<<" PRESS 3 TO QUIT THE GAME";
    cin>>finalchoice;
    if(finalchoice==1)
    goto rematch;
    else if (finalchoice==2)
    goto begin;
    else if(finalchoice==3)
    goto finish;
    else

    break;
    }


    }while(counter<=9 );

    if(flag==0)
    {
    cout<<"THE GAME ENDS IN A DRAW";
    cout<<" THANK YOU FOR PLAYING TIC-TAC-TOE";
    cout<<" PRESS 1 FOR RE-MATCH BETWEEN THE SAME PLAYERS";
    cout<<" PRESS 2 FOR NEW GAME";
    cout<<" PRESS 3 TO QUIT THE GAME";
    cin>>finalchoice;
    if(finalchoice==1)
    goto rematch;
    else if (finalchoice==2)
    goto begin;
    else if(finalchoice==3)
    goto finish;




    }

    getch();
    finish:
    }
    void showgame(char z1,char z2,char z3,char z4,char z5,char z6,char z7,char z8,char z9)
    {
    cout<<"          1       2       3   ";
    cout<<"             |         |       ";
    cout<<"             |         |       ";
    cout<<" 1