Monday 23 July 2012

String Catenation Without Using Strcat Function in C

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

void stringconcatenation(char[],char[]);

void main()
{

    char str1[100],str2[100];
    int compare;

    printf("Enter the first string: ");
   gets(str1);

    printf("Enter the second string: ");
    gets(str2);

    stringconcatenation(str1,str2);

    printf(" The String after concatenation: %s",str1);

    getch();

}

void stringconcatenation(char str1[],char str2[])
{
    int i=0,j=0;
  
  
    while(str1[i]!='\0')
    {
         i++;
    }

    while(str2[j]!='\0')
    {
         str1[i] = str2[j];  
         i++;
         j++;
    }

    str1[i] ='\0';
}

Thursday 19 July 2012

Fibonaaci Series in C


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


int main(void)
{
    int n,a=0,b=1,c=0,i=1;
    printf("How Mnay First Fibonacci Numbers you Want To Generate?\t\t");
    scanf("%d",&n);
    printf("%d %d",a,b);
    while(i<=n-2)
    {
        c=a+b;

        printf("%d",c);

        a=b;

        b=c;
       
         i++;
    }


getch();
return 0;
}

Arrays of Objects in C++

#include<iostream>
#include<string>

using namespace std;

class Employee
{
private:
    char name[30];
    int age;
public:
    void setdata();
    void getdata();
};

void Employee::setdata()
{
    cout<<"\nEnter the name == ";
    cin>>name;

    cout<<"\nEnter the age == ";
    cin>>age;
}

void Employee::getdata()
{
    cout<<"\n\nThe name of employee is == "<<name;
    cout<<"\n\nThe age of employee is == "<<age;
}

const int size = 4;

int main()
{
    Employee supervisor[size];

    for(int i=1;i<=size;i++)
    {
        cout<<"\nDeatail of manager "<<i;
        supervisor[i].setdata();
    }
    cout<<"\n";
    for(int j=1;j<=size;j++)
    {
        cout<<"\n\nManager"<<j;
        supervisor[j].getdata();
    }
    getchar();
    return 0;
}

Arrays within a Class in C++

#include<iostream>
#include<string>


/*Let us consider a shopping list of different items for which we place an order with a dealer.This list includes
details such as the code and the price of each item. We would like to perform operations such as adding an item to the list, deleting an item from a list and printing the total value of the order.*/


using namespace std;

const int  val=50;

class ITEM
{
private:
    int item_code[val];
    int item_price[val];
    int count;
public:
    void initiliaze();
    void get_item();
    void display_item();
    void display_sum();
    void remove();
};
void ITEM::initiliaze()
{
    count=0;
}

void ITEM::get_item()
{
    cout<<"Enter the Item code == "<<endl;
    cin>>item_code[count];

    cout<<"Enter the Item cost == "<<endl;
    cin>>item_price[count];
    count++;
}

void ITEM::display_sum()
{
    int sum=0;
    for(int i=0; i<count;i++)
    {
        sum=sum + item_price[i];
    }
    cout<<"The Total Value Of The Cost Is == "<<sum<<endl;
}

void ITEM::display_item()
{
    cout<<"\nCode  Price\n";
    for(int k=0;k<count;k++)
    {
        cout<<"\n"<<item_code[k];
        cout<<"   "<<item_price[k];
    }
}
void ITEM::remove()
{
    int del;
    cout<<"Enter the code you want to remove == ";
    cin>>del;
    for(int search=0; search<count; search++)
    {
        if(del == item_code[search])
        {
            item_price[search]=0;
            item_code[search]=0;
        }
    }
}


int main()
{
    ITEM order;

    order.initiliaze();
    int x;
    do
    {
        cout<<"\n\nYou have the following opton";
        cout<<"\nEnter the Appropriate number";

        cout<<"\n\nPress 1 for ADD AN ITEMS";
        cout<<"\n\nPress 2 for DISPLAY TOTAL VALUE";
        cout<<"\n\nPress 3 for DELETE AN ITEM";
        cout<<"\n\nPress 4 for DISPLAY ALL ITEMS";
        cout<<"\n\nPress 5 for QUIT";

        cout<<"\nEnter The Desired Number == \n";
        cin>>x;
        switch(x)
        {
        case 1:
            {
                order.get_item();
                break;
            }
        case 2:
            {
                order.display_sum();
                break;
            }
        case 3:
            {
                order.remove();
                break;
            }
        case 4:
            {
                order.display_item();
                break;
            }
        case 5:
            break;
        default: cout<<"Incorrect option Please Press the right number == ";
        }

    }while(x!=5);

    getchar();
    return 0;
}

Wednesday 18 July 2012

OOP: Composition in C++

#include<iostream>
#include<string>

using namespace std;


class employee
{
private: string employee_name;
public: employee(string name)
        {
            employee_name=name;
        }
public: string get_employee_name()
        {
            return employee_name;
        }
public: void show_employee_name()
        {
            cout<<"The name of the employee of this organization is == "<<employee_name<<endl;
        }

};
class organization
{
private: string organization_name;
         employee *myemployee;
public: organization(string name_of_employee, string name_of_organization)
        {
            myemployee=new employee(name_of_employee);
            organization_name=name_of_organization;
        }
public: void show()
        {
            cout<<"The organization name is == "<<organization_name<<endl;
            myemployee->show_employee_name();
        }
};
int main()
{
    string org_name,employ_name;
    cout<<"This is the organization structure"<<endl;
    cout<<"Enter the organization name == ";
    getline(cin,org_name);
    cout<<"Enter the name of employee == "<<endl;
    getline(cin,employ_name);
    organization myorganization(employ_name,org_name);
    myorganization.show();



    getchar();
    getchar();
    return 0;
}

Saturday 14 July 2012

Recursion: Program to Convert Decimal To Binary


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

void Dec_To_Bin (int num);

void main ()
{
int num;
int base;
clrscr();

printf ("Enter the decimal number to convert it binary.\n");
scanf ("%d", &num);


printf ("The %d in binary is : ", num);
Dec_To_Bin (num);

   getch();
}

void Dec_To_Bin (int num)
{

if (num > 1)
{
Dec_To_Bin ((num / 2));
}

printf ("%d", (num % 2));

}

Program To Convert Octal To Binary


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


float octal_conversion(int octal);

void main()
{
int octal,answer;

clrscr();

printf("program which convert octal to decimal\n\n");

printf("Enter a number in octal form= ");
scanf("%d",&octal );


answer = octal_conversion(octal);
if(answer == 8)
{
printf("wrong");
}
else
{
printf("The result is %d", answer);
}

getch();

}







float octal_conversion(int octal)
{
int square;
int remainder;
int i = 0;
int result=0 ;

while(octal > 0)
{

remainder = octal % 10;
square=pow(8,i);
if(remainder<=7)
{
result = result + square * remainder;

}
else
{

return 8;
}
octal = octal / 10;
i++;

}

return result;
 }

Calculate HCF in C


#include<stdio.h>
#include<conio.h>
int hcf(int n1 ,int n2);
void main()
{
int n1,n2;
clrscr();
printf("enter the two number =");
scanf("\n%d\n%d",&n1 ,&n2);


printf("\n HCF of two numbers is =%d",hcf(n1,n2));

getch();
}


int hcf(int n1 ,int n2)
{
int i,minimum,u;
if (n1>n2)
{
minimum=n2;
}
else
{
minimum=n1;
}

for(i=minimum;i>=1;i--)
{
if(n1%i==0 && n2%i==0)
{
  u=i;
return u;
  }

}
  }

OOP : Aggregation in C++

#include<string>
#include<iostream>

using namespace std;

class Mobile
{
public: string IMEI_NO;
public: string Model;
public: Mobile(string im_no,string model)
        {
            IMEI_NO=im_no;
            Model=model;
        }
public: void show()
        {
            cout<<"IMEI no is == "<<IMEI_NO<<endl;
            cout<<"Model of your mobile is == "<<Model<<endl;
        }
};


class Person
{
    Mobile *mymobile;
public: string name;
public: string CNIC;
public: Person(string n , string c)
        {
            name=n;
            CNIC=c;
        }
public: void show()
        {
            cout<<"The name of the person is == "<<name<<endl;
            cout<<"The CNIC of a particular person is == "<<CNIC<<endl;
            mymobile->show();       
        }
public:void setmobile(Mobile * m1)
        {
            mymobile=m1;
        }
};

int main()
{
    Mobile *mob;
    mob=new Mobile("12589874458580","nokia 3310");
    Person myperson("Anonymous","37405-58925986-5");

    myperson.setmobile(mob);
    myperson.show();

    getchar();
    return 0;
}

Friday 13 July 2012

Calculate LCM in C


#include<stdio.h>
#include<conio.h>
int lcm(int n1,int n2);
void main()
{
  int n1,n2,x,y;
  clrscr();
  printf("\nEnter two numbers:");
  scanf("%d %d",&n1,&n2);

  printf("L.C.M is=%d",lcm(n1,n2));

  getch();
 }

// Function Definition


    int lcm(int n1,int n2)
  {
  int x,y,u;
  x=n1,y=n2;
  while(n1!=n2)
  {
if(n1>n2)
{
  n1=n1-n2;
}
 else
{
n2=n2-n1;
}
  }

u=(x*y)/n1;
return u;
   }

Calculate Power Of A Number in C


#include<stdio.h>
#include<conio.h>
void main()
{
long int a,b,c,i,j,d,u;

clrscr();

printf("enter base =");
scanf("%ld",&a);

u=a;

printf("\nenter exponent =");
scanf("%ld",&b);


for(i=0;i<b;i++)
{

    c=a*u;
    a=c;

  }


if(b==1)
{
c=c/u;

}

 printf("%ld",c);
 getch();
 }

Calculate Factorial in C

#include<stdio.h>
#include<conio.h>
void main()
{
long int multiply,num;
long int i=0,a,value,sum;

clrscr();

printf("enter number which you find the factorial =");
scanf("%ld",& num);

multiply=num;
value=num;
a=num-1;

while(i++<a)
{
    sum=value-i;
    multiply=multiply*sum;

}
printf("%ld",multiply);
getche();
}

Prime Numbers in C


#include<stdio.h>
#include<conio.h>
void main()
{
int num2,num1,c,i;
clrscr();
printf("enter the starting number =");
scanf("%d",&num1);

printf("\n\nenter the ending number =");
scanf("%d",&num2);

for(i=num1;i<=num2;i++)
{
for(c=2;c<=i-1;c++)
{
if(i%c==0)
break;
}
if(i==c)
{
printf("\n\n%d",i);
}
}

 getch();
 }

Transpose Of A Matrix In C


#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],i,j;
clrscr();
printf("enter the matrix =\n");
for(i=0;i<3;i++)
{
  for(j=0;j<3;j++)
  {
  scanf("%d",&a[i][j]);
  }
}


clrscr();


printf("your matrix is =\n");
  for(i=0;i<3;i++)
  {
  printf("\n");
  for(j=0;j<3;j++)
{
    printf("%d      |\t",a[i][j]);
  }
  }



  for(i=0;i<3;i++)
  {
  for(j=0;j<3;j++)
  {
  b[i][j]=a[j][i];
  }
  }



  printf("\n\nthe transpose is =\n");

  for(i=0;i<3;i++)
  {
    printf("\n");
    for(j=0;j<3;j++)
    {
    printf("%d      |\t",b[i][j]);
    }
  }
   getch();
   }

Thursday 12 July 2012

Check Palindrome in C


#include <stdio.h>
#include <string.h>
void main()
{
char string[20];
int i, j, length=0, flag=0;

printf("\nEnter The desired String string: ");
gets(string);
for (i=0; string[i]!='\0'; i++)
{
length++;
i = 0;
j = length-1;
while (i < length)
{
if (string[i] != string[j])
{
flag = 1;
break;
}
i++;
j--;
}
if (flag == 0)
{
printf("\n Your Desired String is palindrome");
}
else
{
printf("\nYour Desired String is not palindrome");
}
getch();

}

Addition Of Matrix In C


#include<stdio.h>
#include<conio.h>
void main()
{

  int a[3][3],b[3][3],end[3][3],i,j;
clrscr();
  printf("Enter Your First matrix");
  for(i=0;i<3;i++)
{
      for(j=0;j<3;j++)
{
          scanf("%d",&a[i][j]);
}
}


  printf("\nEnter Your Second matrix");
  for(i=0;i<3;i++)
{
      for(j=0;j<3;j++)
{
            scanf("%d",&b[i][j]);
}
}
   clrscr();
  printf("\nFirst matrix is\n");
  for(i=0;i<3;i++)
{
      printf("\n");
      for(j=0;j<3;j++)
{
          printf("%d\t",a[i][j]);
}
  }


  printf("\n Second matrix is\n");
  for(i=0;i<3;i++)
{
      printf("\n");
      for(j=0;j<3;j++)
{
      printf("%d\t",b[i][j]);
  }
}



    for(i=0;i<3;i++)
{
       for(j=0;j<3;j++)
{
            end[i][j]=a[i][j]+b[i][j];

}
}


   printf("\n Here is the Addition of two matrix is\n");
  for(i=0;i<3;i++)
{
       printf("\n");
        for(j=0;j<3;j++)
{
            printf("%d\t",end[i][j]);
  }
}
 getch();
}

SUM OF LARGE NUMBERS BY USING ARRYS


#include<stdio.h>
#include<conio.h>
#include<string.h>
/* (SUM OF LARGE NUMBERS BY USING ARRYS)*/




void main()
{
char arr1[100], arr2[100];


int f,ans[100]={0,0},x,size1=0,size2=0,value1[100]={0,0},value2[100]={0,0},value3[100]={0,0},cout=0,i=0,sum;


clrscr();


printf("enter your first number");
gets(arr1);


printf("enter your second number");
gets(arr2);
size1=strlen(arr1);

size2=strlen(arr2);

for(x=0;x<size1;x++)
{
value1[x]=arr1[x];
value1[x]=value1[x]-48;
}
for(x=0;x<size2;x++)
{
value2[x]=arr2[x];
value2[x]=value2[x]-48;
}


printf("\n");

for(x=0;x<size1;x++)
{
printf("%d\n",value1[x]);
}
printf("\n\n");

for(x=0;x<size2;x++)
{
printf("%d\n",value2[x]);
}


if(size1>size2)
{
cout=size1;
f=size1-size2;
for(x=0;x<size2;x++)
{
value3[f]=value2[x];
value2[x]=0;
f++;
}
for(x=0;x<size1;x++)
{
value2[x]=value3[x];
}
}


if(size2>size1)
{
cout=size2;
f=size2-size1;
for(x=0;x<size1;x++)
{
value3[f]=value1[x];
value1[x]=0;
f++;
}
for(x=0;x<size2;x++)
{
value1[x]=value3[x];
}
}
if(size1==size2)
{
cout=size1;
}
 clrscr();

printf("\n");

for(x=0;x<cout;x++)
{
printf("%d\t|",value1[x]);

}
printf("\n\n");

for(x=0;x<cout;x++)
{
printf("%d\t|",value2[x]);
}





for (i=cout-1;i>=0;i--)
{
sum=value1[i]+value2[i];
if(sum>=10)
{
ans[i]+=sum%10;
ans[i-1]+=sum/10;
}

if(sum<10)
{
ans[i]=ans[i]+sum;
if(ans[i]>=10)
{
ans[i-1]+=ans[i]/10;
ans[i]=ans[i]%10;
}

}

}



printf("\n\n____________________________________________________  \n\n | ");


for(i=0;i<cout;i++)
{
printf(" %d\t|",ans[i]);
}
getche();

}

Print Right Angle Triangle Shape in C


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();

for(i=1;i<=10;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}

getch();
}

To Reverse Two Numbers in C


#include<stdio.h>
#include<conio.h>
void main()

{
int a,b,c;

printf("\n\nenter a number");
scanf("%d",&a);

b=a%10;

c=a/10;

printf("%d",b);
printf("%d",c);
getche();
}

Print Greater Or Smaller Number in C


#include<stdio.h>
#include<conio.h>
void main()
{
  int a,b;

  printf("enter the value of a");
  scanf("%d",&a);

  printf("enter the value of b");
  scanf("%d",&b);


if (a>b);
  {
printf("a is greater than b");
    printf("b is less than a");
}

if (a<b);

  {
printf("b is greater than a");
  printf("a is less than b");
}

  getch;      
}

Print Even Or Odd in C


#include<stdio.h>
#include<conio.h>
void main()

{
int a;

    clrscr();

  printf("\n\nenter a number=");
  scanf("%d",&a);

  if(a%2==0)
    {
printf("\n\ngiven number is even");
  }

    if (a%2==1)
 {
printf("\ngiven number is ood");
}
getch();    
 }

Pirnt BOX shape in C


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a,b,c,d;
  char hamza;
  clrscr();

printf("enter height");
scanf("%d",&a);

printf("enter your desire symbol =");
hamza=getche();
clrscr();

b=a+a;
c=b/2;
d=c+1;
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
if((j==1)||(j==c)||(j==d)||(j==b)||(i==1)||(i==a))
{
printf("%c",hamza);
}
else
{
printf(" ");
}
}
printf("\n");
}
getch();
}

Print Alphabet "B" in C


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,e,l;
       clrscr();
       e=6/2;
       l=e+1;

for(i=1;i<=6;i++)

{
for(j=1;j<=6;j++)
{
if((j==1)||(j==6)||(i==1)||(i==6)||(i==l))
{
printf("*");
}
else

{
printf(" ");
}
}
printf("\n");
}
   getch();
}


Calculate Average in C



 #include<stdio.h>
 #include<conio.h>
 void main()



 {
    int a,b,c,d,e;

    clrscr;

  printf("enter the value of a");
  scanf("%d",&a);

  printf("enter the value of b");
  scanf("%d",&b);

  printf("enter the value of c");
  scanf("%d",&c);

  printf("enter the value of d");
  scanf("%d",&d)

  e=(a+b+c+d)/4;     // Average Formula

  printf("%d",e);

  getch;      
 }

Wednesday 11 July 2012

Print Alphabet "I" in C


#include<stdio.h>
#include<conio.h>
void main()
{
  int i,p,a;
clrscr();
printf("enter the height =");
scanf("%d",&a);
for(i=1;i<=a;i++)
  {
  printf("*\n");
  }

 getch();
 }

Print Alphabet "I" in C


#include<stdio.h>
#include<conio.h>
void main()
{
  int i,p,a;
clrscr();
printf("enter the height =");
scanf("%d",&a);
for(i=1;i<=a;i++)
  {
  printf("*\n");
  }

 getch();
 }

Print Alphabet "L" in C


#include<stdio.h>
#include<conio.h>
void main()
{
int i,p,a;
clrscr();
  printf("enter the height =");
  scanf("%d",&a);
    for(i=1;i<=a;i++)
 {
  printf("*\n");
  }
   if(i==a+1)
  {
    for(p=1;p<=a;p++)
  {
    printf("*");
    }
    }
    getch();
}

Print Alphabet "M" in C


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


void main()
{
int i,j,b,a,r,g;
clrscr();
printf("enter height =");
scanf("%d",&a);
r=a+a;
g=r-1;
b=a+(a-1);
       for(i=1;i<=a;i++)
      {
for(j=0;j<=b;j++)
  {
  if((j==1)||(i==j)||(j==g)||(i==a-j+a))
    {
    printf("*");
    }
else
  {
  printf(" ");
   }
   }
   printf("\n");
   }


getch();
 }

Print Alphabet "V" in C


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,b,a;
clrscr();
printf("enter height =");
scanf("%d",&a);
b=a+(a-1);
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
if((i==j)||(i==a-j+a))
{
printf("*");
}
else
{
printf(" ");
}
   }
   printf("\n");
}
   getch();
}

Print Alphabet "X" in C


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a;
clrscr();
printf("enter height =");
scanf("%d",&a);
         for(i=1;i<=a;i++)
         {
for(j=1;j<=a;j++)
  {
    if((i==j)||(i==a-j+1))
    {
    printf("*");
      }
    else
    {
     printf(" ");
     }

      }
     printf("\n");
     }

getch();
}

Print Alphabet "F" in C


#include<stdio.h>
#include<conio.h>
void main()
{
 int i,j,c,d,p,a;
 clrscr();
 printf("enter height =");
 scanf("%d",&a);
 c=a+1;
 d=c/2;

      for(i=1;i<=a;i++)
      {
    for(j=1;j<=a;j++)
    {
     if((i==1)||(i==d))
      {
       for(p=1;p<=a;p++)
{
printf("*");
}
break;
}
}
printf("*\n");
     }
getch();
}

Print Alphabet "H" in C



#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,p,w,m,n;

clrscr();
printf("enter height =");
scanf("%d",&w);
m=w+1;
n=m/2;
for(a=1;a<=w;a++)
 {

  printf("*");

  for(b=1;b<=w;b++)
  {
   if(a==n)
    {
    for(p=1;p<=w;p++)
    {
    printf("*");
}
break;
     }
    printf(" ");
    }
    printf("*\n");
   }
   getch();
}

TIC TAC TOE game in C



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


void main()
{
int i,decision;
char po11= '7' , po12='8' , po13= '9' , po21='4' , po22='5' , po23='6' , po31='1' ,po32='2' ,po33='3';
clrscr();

printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);

for(i=1;i<=10;i++)
{

if(i==1||i==3||i==5||i==7||i==9)
{
printf(" player one where u want to enter press number = ");
scanf("%d",&decision);

      switch(decision)
      {
case 1:
if(po31=='1')
{
po31='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}
break;

case 2:
if(po32=='2')
{
po32='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;


case 3:
if(po33=='3')
{
po33='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;


case 4:
if(po21=='4')
{
po21='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;


case 5:
if(po22=='5')
{
po22='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;



case 6:
if(po23=='6')
{
po23='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}
break;


case 7:
if(po11=='7')
{
po11='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;


case 8:
if(po12=='8')
{
po12='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;



case 9:
if(po13=='9')
{
po13='X';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}
break;


      }

}


else if(i==2||i==4||i==6||i==8)
{
printf("\n player two where u want to enter press number = ");
scanf("%d",&decision);


      switch(decision)
      {
case 1:
if(po31=='1')
{
po31='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}
break;


case 2:
if(po32=='2')
{
po32='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;



case 3:
if(po33=='3')
{
po33='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;



case 4:
if(po21=='4')
{
po21='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;



case 5:
if(po22=='5')
{
po22='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;




case 6:
if(po23=='6')
{
po23='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}
break;




case 7:
if(po11=='7')
{
po11='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;



case 8:
if(po12=='8')
{
po12='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}

break;


case 9:
if(po13=='9')
{
po13='O';
printf(" %c | %c | %c \n", po11, po12, po13);
printf(" %c | %c | %c \n", po21, po22, po23);
printf(" %c | %c | %c \n\n\n\n", po31, po32, po33);
}
break;


      }

}


if(po11==po12 && po11==po13||po21==po22 && po21==po23||po31==po32 && po31== po33)
{
    if(po11=='X'||po21=='X'||po31=='X')
    {
    printf("player one win");
    break;
    }
    else
    {
    printf("player two win");
    break;
    }
}



else if(po11==po21 && po11==po31||po12==po22 && po12==po32||po13==po23 && po13== po33)
{
   if(po11=='X'||po12=='X'||po13=='X')
    {
    printf("player one win");
    break;
    }
    else
    {
    printf("player two win");
    break;
    }
}





else if(po11==po22 && po11==po33||po13==po22 && po13==po31)
{
   if(po11=='X'||po13=='X')
   {
   printf("player one win");
   break;
   }
   else
   {
   printf("player two win");
   break;
   }
}

}
getche();


}