Showing posts with label class. Show all posts
Showing posts with label class. Show all posts
on Monday, 20 January 2014
#include<iostream.h>
 #include<conio.h>

 int largest(int,int,int);

 main()
    {
       clrscr();


       int value_1;
       int value_2;
       int value_3;
       int maximum;

       cout<<"\n Enter the value_1 =  ";
       cin>>value_1;

       cout<<"\n Enter the value_2 =  ";
       cin>>value_2;

       cout<<"\n Enter the value_3 =  ";
       cin>>value_3;

       maximum=largest(value_1,value_2,value_3);

       cout<<"\n The largest integer is = "<<maximum<<endl;

       getch();
       return 0;
    }

 /*************************************************************************///-------------------------  largest(int,int,int)  ----------------------///*************************************************************************/int largest(int x,int y,int z)
    {
       int largest=x;

       if(y>largest)
      largest=y;

       if(z>largest)
      largest=z;

       return largest;
    }
# include <iostream.h>
 # include <graphics.h>
 # include    <conio.h>
 # include     <math.h>

 # define  f                 0.3
 # define  projection_angle   45

 void show_screen( );

 void Bezier_curve(constint,constint [4][3]);
 void Piece_wise_bezier_curve(constint,constint [25][3]);

 double nCr(int,int);
 double factorial(int);

 void get_projected_point(double&,double&,double&);
 void multiply_matrices(constfloat[4],constfloat[4][4],float[4]);

 void Dashed_line(constint,constint,constint,constint,constint=0);


 int main( )
    {
       int driver=VGA;
       int mode=VGAHI;

       int n;

       do
      {
         show_screen( );

         gotoxy(8,10);
         cout<<"Number of Control Points : n :";

         gotoxy(8,11);
         cout<<"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ";

         gotoxy(12,13);
         cout<<"Enter the value of n (1<n<=25) = ";
         cin>>n;

         if(n>=10)
        n=10;

         int control_points[25][3]={0};

         for(int count=0;count<n;count++)
        {
           gotoxy(8,16);
           cout<<"Coordinates of Point-"<<count<<" (x"<<count<<",y"<<count<<",z"<<count<<") :";

           gotoxy(8,17);
           cout<<"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ";

           gotoxy(12,19);
           cout<<"Enter the value of x"<<count<<" = ";
           cin>>control_points[count][0];

           gotoxy(12,21);
           cout<<"Enter the value of y"<<count<<" = ";
           cin>>control_points[count][1];

           gotoxy(12,23);
           cout<<"Enter the value of z"<<count<<" = ";
           cin>>control_points[count][2];

           gotoxy(8,16);
           cout<<"                                            ";

           gotoxy(12,19);
           cout<<"                                            ";

           gotoxy(12,21);
           cout<<"                                            ";

           gotoxy(12,23);
           cout<<"                                            ";
        }

         initgraph(&driver,&mode,"..\\Bgi");

         setcolor(15);
           Piece_wise_bezier_curve(n,control_points);

         setcolor(15);
           outtextxy(110,460,"Press <Enter> to continue or any other key to exit.");

         int key=int(getch( ));

         if(key!=13)
        break;
      }
       while(1);

       return 0;
    }

void Piece_wise_bezier_curve(constint n,constint cpts[25][3])
    {
       int pieces=(n/4);
       int extra_points=(n%4);

       int point=1;

       int cp[4][3]={0};

       for(int count_1=0;count_1<pieces;count_1++)
      {
         point--;

         for(int count_2=0;count_2<4;count_2++)
        {
           cp[count_2][0]=cpts[point][0];
           cp[count_2][1]=cpts[point][1];
           cp[count_2][2]=cpts[point][2];

           point++;
        }

         Bezier_curve(3,cp);
      }

       if(extra_points)
      {
         for(int count_3=(point-1),count_4=0;count_3<n;
                            count_3++,count_4++)
        {
           cp[count_4][0]=cpts[count_3][0];
           cp[count_4][1]=cpts[count_3][1];
           cp[count_4][2]=cpts[count_3][2];
        }

         Bezier_curve(extra_points,cp);
      }
    }

void Bezier_curve(constint n,constint cp[4][3])
    {
       setcolor(7);

       double x_1;
       double y_1;
       double z_1;
       double x_2;
       double y_2;
       double z_2;

       for(int count=0;count<n;count++)
      {
         x_1=cp[count][0];
         y_1=cp[count][1];
         z_1=cp[count][2];
         x_2=cp[(count+1)][0];
         y_2=cp[(count+1)][1];
         z_2=cp[(count+1)][2];

         get_projected_point(x_1,y_1,z_1);
         get_projected_point(x_2,y_2,z_2);

         Dashed_line((int)(x_1+0.5),(int)(y_1+0.5),
                         (int)(x_2+0.5),(int)(y_2+0.5));
      }

       double x;
       double y;
       double z;

       for(float u=0.0005;u<=1;u+=0.0005)
      {
         x=0;
         y=0;
         z=0;

         for(int k=0;k<=n;k++)
        {
           x+=(cp[k][0]*nCr(n,k)*pow(u,k)*powl((1-u),(n-k)));
           y+=(cp[k][1]*nCr(n,k)*pow(u,k)*powl((1-u),(n-k)));
           z+=(cp[k][2]*nCr(n,k)*pow(u,k)*powl((1-u),(n-k)));
        }

         get_projected_point(x,y,z);

         putpixel((int)(x+0.5),(int)(y+0.5),15);
      }
    }

double nCr(int n,int r)
    {
       double nf;
       double rf;
       double nrf;
       double ncr;

       nf=factorial(n);
       rf=factorial(r);
       nrf=factorial((n-r));

       ncr=(nf/(rf*nrf));

       return ncr;
    }

double factorial(int number)
    {
       double factorial=1;

       if(number==0 || number==1);

       else
      {
         for(int count=1;count<=number;count++)
        factorial=factorial*count;
      }

       return factorial;
    }

void get_projected_point(double& x,double& y,double& z)
    {
       float fcos0=(f*cos(projection_angle*(M_PI/180)));
       float fsin0=(f*sin(projection_angle*(M_PI/180)));

       float Par_v[4][4]={
                {1,0,0,0},
                {0,1,0,0},
                {fcos0,fsin0,0,0},
                {0,0,0,1}
             };

       float xy[4]={x,y,z,1};
       float new_xy[4]={0};

       multiply_matrices(xy,Par_v,new_xy);

       x=new_xy[0];
       y=new_xy[1];
       z=new_xy[2];
    }

void multiply_matrices(constfloat matrix_1[4],
                  constfloat matrix_2[4][4],float matrix_3[4])
    {
       for(int count_1=0;count_1<4;count_1++)
      {
         for(int count_2=0;count_2<4;count_2++)
        matrix_3[count_1]+=
               (matrix_1[count_2]*matrix_2[count_2][count_1]);
      }
    }

void Dashed_line(constint x_1,constint y_1,constint x_2,
                      constint y_2,constint line_type)
    {
       int count=0;
       int color=getcolor( );

       int x1=x_1;
       int y1=y_1;

       int x2=x_2;
       int y2=y_2;

       if(x_1>x_2)
      {
         x1=x_2;
         y1=y_2;

         x2=x_1;
         y2=y_1;
      }

       int dx=abs(x2-x1);
       int dy=abs(y2-y1);
       int inc_dec=((y2>=y1)?1:-1);

       if(dx>dy)
      {
         int two_dy=(2*dy);
         int two_dy_dx=(2*(dy-dx));
         int p=((2*dy)-dx);

         int x=x1;
         int y=y1;

         putpixel(x,y,color);

         while(x<x2)
        {
           x++;

           if(p<0)
              p+=two_dy;

           else
              {
             y+=inc_dec;
             p+=two_dy_dx;
              }

           if((count%2)!=0 && line_type==0)
              putpixel(x,y,color);

           elseif((count%5)!=4 && line_type==1)
              putpixel(x,y,color);

           elseif((count%10)!=8 && (count%10)!=9 && line_type==2)
              putpixel(x,y,color);

           elseif((count%20)!=18 && (count%20)!=19 && line_type==3)
              putpixel(x,y,color);

           elseif((count%12)!=7 && (count%12)!=8 &&
                (count%12)!=10 && (count%12)!=11 && line_type==4)
              putpixel(x,y,color);

           count++;
        }
      }

       else
      {
         int two_dx=(2*dx);
         int two_dx_dy=(2*(dx-dy));
         int p=((2*dx)-dy);

         int x=x1;
         int y=y1;

         putpixel(x,y,color);

         while(y!=y2)
        {
           y+=inc_dec;

           if(p<0)
              p+=two_dx;

           else
              {
             x++;
             p+=two_dx_dy;
              }

           if((count%2)!=0 && line_type==0)
              putpixel(x,y,color);

           elseif((count%5)!=4 && line_type==1)
              putpixel(x,y,color);

           elseif((count%10)!=8 && (count%10)!=9 && line_type==2)
              putpixel(x,y,color);

           elseif((count%20)!=18 && (count%20)!=19 && line_type==3)
              putpixel(x,y,color);

           elseif((count%12)!=7 && (count%12)!=8 &&
                (count%12)!=10 && (count%12)!=11 && line_type==4)
              putpixel(x,y,color);

           count++;
        }
      }
    }

void show_screen( )
    {
       restorecrtmode( );
       clrscr( );
       textmode(C4350);

       cprintf("\n********************************************************************************");
       cprintf("*-***********************-                           -************************-*");
       cprintf("*------------------------- ");

       textbackground(1);
       cprintf(" Piece-Wise Bezier Curve ");
       textbackground(8);

       cprintf(" --------------------------*");
       cprintf("*-***********************-                           -************************-*");
       cprintf("*-****************************************************************************-*");

       for(int count=0;count<42;count++)
      cprintf("*-*                                                                          *-*");

       gotoxy(1,46);
       cprintf("*-****************************************************************************-*");
       cprintf("*------------------------------------------------------------------------------*");
       cprintf("********************************************************************************");

       gotoxy(1,2);
    }

#include<iostream.h>
#include<conio.h>
void kal(int *a,int *b)
{
    int *temp,i;
    temp=&i;
    *temp=*a;
    *a=*b;
    *b=*temp;
}

main()
{
    clrscr();
    int i=5,j=10;
    cout<<"Before swapping I = "<<i<<" J = "<<j<<endl;
    kal(&i,&j);
    cout<<"After swapping I = "<<i<<" J = "<<j<<endl;
}
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <iomanip.h>
#include <conio.h>

class phoneBook{
    char name[20],phno[15];
    public:
    void getdata();
    void showdata();
    char *getname(){ return name; }
    char *getphno(){ return phno; }
    void update(char *nm,char *telno){
        strcpy(name,nm);
        strcpy(phno,telno);
    }
};

void phoneBook :: getdata(){
    cout<<"\nEnter Name : ";
    cin>>name;
    cout<<"Enter Phone No. : ";
    cin>>phno;
}

void phoneBook :: showdata(){
    cout<<"\n";
    cout<<setw(20)<<name;
    cout<<setw(15)<<phno;
}


void main(){
    phoneBook rec;
    fstream file;
    file.open("d:\\phone.dat", ios::ate | ios::in | ios::out | ios::binary);
    char ch,nm[20],telno[6];
    int choice,found=0;
    while(1){
        clrscr();
        cout<<"\n*****Phone Book*****\n";
        cout<<"1) Add New Record\n";
        cout<<"2) Display All Records\n";
        cout<<"3) Search Telephone No.\n";
        cout<<"4) Search Person Name\n";
        cout<<"5) Update Telephone No.\n";
        cout<<"6) Exit\n";
        cout<<"Choose your choice : ";
        cin>>choice;
        switch(choice){
            case 1 : //New Record
                 rec.getdata();
                 cin.get(ch);
                 file.write((char *) &rec, sizeof(rec));
                 break;

            case 2 : //Display All Records
                 file.seekg(0,ios::beg);
                 cout<<"\n\nRecords in Phone Book\n";
                 while(file){
                    file.read((char *) &rec, sizeof(rec));
                    if(!file.eof())
                        rec.showdata();
                 }
                 file.clear();
                 getch();
                 break;

            case 3 : //Search Tel. no. when person name is known.
                 cout<<"\n\nEnter Name : ";
                 cin>>nm;
                 file.seekg(0,ios::beg);
                 found=0;
                 while(file.read((char *) &rec, sizeof(rec)))
                 {
                    if(strcmp(nm,rec.getname())==0)
                    {
                        found=1;
                        rec.showdata();
                    }
                 }
                 file.clear();
                 if(found==0)
                    cout<<"\n\n---Record Not found---\n";
                 getch();
                 break;

            case 4 : //Search name on basis of tel. no
                 cout<<"\n\nEnter Telephone No : ";
                 cin>>telno;
                 file.seekg(0,ios::beg);
                 found=0;
                 while(file.read((char *) &rec, sizeof(rec)))
                 {
                    if(strcmp(telno,rec.getphno())==0)
                    {
                        found=1;
                        rec.showdata();
                    }
                 }
                 file.clear();
                 if(found==0)
                    cout<<"\n\n---Record Not found---\n";
                 getch();
                 break;

            case 5 : //Update Telephone No.
                 cout<<"\n\nEnter Name : ";
                 cin>>nm;
                 file.seekg(0,ios::beg);
                 found=0;
                 int cnt=0;
                 while(file.read((char *) &rec, sizeof(rec)))
                 {
                    cnt++;
                    if(strcmp(nm,rec.getname())==0)
                    {
                        found=1;
                        break;
                    }
                 }
                 file.clear();
                 if(found==0)
                    cout<<"\n\n---Record Not found---\n";
                 else
                 {
                    int location = (cnt-1) * sizeof(rec);
                    cin.get(ch);
                    if(file.eof())
                        file.clear();

                    cout<<"Enter New Telephone No : ";
                    cin>>telno;
                    file.seekp(location);
                    rec.update(nm,telno);
                    file.write((char *) &rec, sizeof(rec));
                    file.flush();
                 }
                 break;
            case 6 : gotoout;
        }
    }
out:
file.close();
}[/Code]
on Sunday, 19 January 2014
#include <iostream.h>
#include <stdlib.h>  //for exit()
#include <conio.h>
#include <dos.h>
#define row 7
#define col 5


class revpol{
      int top,rank;
      char *stack_arr,*polish,*infix;
      public:
      int f(char);  //Input precedence functionint g(char);  //Stack precedence functionint r(char);  //rank functionvoid push(char);
      char pop();
      char *concat(char *,char);
      void suffix();//infix to suffix conversion functionvoid printStack();
      void printSuffix();
      void printRank();
      void printInfix(char);
};

void revpol :: printInfix(char ch){
    staticint y=row,x=col;
    gotoxy(x,y++);
    cout<<ch;
}

void revpol :: printStack(){
     staticint x=col,y=row;
     gotoxy(x+10,y++);
     cout<<stack_arr;
}

void revpol :: printSuffix(){
     staticint x=col,y=row;
     gotoxy(x+30,y++);
     cout<<polish;
}

void revpol :: printRank(){
     staticint x=col,y=row;
     gotoxy(x+50,y++);
     cout<<rank;
}

int revpol :: f(char inputchar){
     if(inputchar==')')
      return(0);
     elseif(inputchar=='+' || inputchar=='-')
      return(1);
     elseif(inputchar=='*' || inputchar=='/')
      return(3);
     elseif(inputchar=='^')
      return(6);
     elseif(inputchar>='a' || inputchar<='z')
      return(7);
     elseif(inputchar>='A' || inputchar<='Z')
      return(7);
     elseif(inputchar=='(')
      return(9);
     elsereturn(-99);  //for error
}

int revpol :: g(char inputchar){
     if(inputchar=='(')
      return(0);
     elseif(inputchar=='+' || inputchar=='-')
      return(2);
     elseif(inputchar=='*' || inputchar=='/')
      return(4);
     elseif(inputchar=='^')
      return(5);
     elseif(inputchar>='a' || inputchar<='z')
      return(8);
     elseif(inputchar>='A' || inputchar<='Z')
      return(8);
     elsereturn(-99);  //for error
}


int revpol :: r(char inputchar){
     if(inputchar=='+' || inputchar=='-' || inputchar=='*' || inputchar=='/'|| inputchar=='^')
      return(-1);
     elseif(inputchar>='a' || inputchar<='z')
      return(1);
     elseif(inputchar>='A' || inputchar<='Z')
      return(1);
     elsereturn(-99);  //for error
}


void revpol :: push(char charin){
     top++;
     stack_arr[top]=charin;
     stack_arr[top+1]='\0';
}

char revpol :: pop(){
     char popdata;
     popdata=stack_arr[top];
     stack_arr[top]='\0';
     top--;
     return(popdata);
}

char * revpol :: concat(char *polish,char temp){
     int i;
     for(i=0;polish[i]!='\0';i++);
     polish[i]=temp;
     polish[i+1]='\0';
     return(polish);
}

void revpol :: suffix(){
     int i;
     char next,temp;

     //initialize the stack
     top=0;
     stack_arr[top]='(';

     //Intialize output string and rank count
     polish="";
     rank=0;

     textcolor(LIGHTGREEN);
     gotoxy(2,24);
     cprintf("E-Mail  :  find@myblog.com");
     gotoxy(2,25);
     cprintf("Website :  http://dotnetguts.blogspot.com ");

     gotoxy(1,1);
     textcolor(LIGHTMAGENTA);
     cprintf("*****INFIX TO POSTFIX (Paranthesized)*****\r\n");
     textcolor(WHITE);
     cprintf("Enter Infix string : ");
     cin>>infix;
     infix=concat(infix,')');

     textcolor(LIGHTBLUE);
     gotoxy(2,5);
     cprintf("INFIX");
     gotoxy(15,5);
     cprintf("STACK");
     gotoxy(35,5);
     cprintf("SUFFIX");
     gotoxy(53,5);
     cprintf("RANK");

     gotoxy(15,6);
     cout<<"(";
     cout<<endl;


     //Remove symbols with greater precedence from stackfor(i=0;infix[i]!='\0';i++){
     //obtain next input symbol
     next=infix[i];
     cout<<endl;
     printInfix(next);

     if(top<0){
        cout<<"\n\n\tInvali Infix";
        getch();
        exit(1);
     }
     while(f(next) < g(stack_arr[top])){
           temp=pop();
           polish=concat(polish,temp);
           rank = rank + r(temp);
           if(rank<1){
          cout<<"\n\n\tInvalid Infix";
          getch();
          exit(1);
           }
     }
     //Are there matching parentheses?if(f(next) != g(stack_arr[top]))
         push(next);
     else
         temp=pop();  //here value in temp is of no use
     delay(200);
     printStack();
     printSuffix();
     printRank();
     }


      //Check whether expression is invalidif(rank!=1 || top!=-1){
         textcolor(RED + BLINK);
         cprintf("\r\n\r\nInvalid Infix");
      }
      else{
        textcolor(LIGHTGREEN + BLINK);
        cprintf("\r\n\r\nvalid Infix");
        textcolor(YELLOW);
        cprintf("\r\nSuffix : %s",polish);
      }
      _setcursortype(_NOCURSOR);
}

void main(){
     clrscr();
     revpol obj;
     obj.suffix();
     getch();
}
[/Code]
#include <iostream.h>
#include <conio.h>

class sel_search
{
int d[50],s,search_val;
public:
void getdata(void);
int search(void);
void display(void);
};

void sel_search :: getdata(void)
{
cout<<endl<<endl;
cout<<"How many size of array you want to create:-";
cin>>s;
cout<<"Enter "<<s<<" Integers\n";
for(int i=0;i<s;i++)
    cin>>d[i];
cout<<"\n\nEnter your search:-";
cin>>search_val;
}

int  sel_search :: search(void)
{
for(int i=0;i<s;i++)
{
    if(d[i]==search_val)
           return(i+1);
}
return(-1);
}

void sel_search :: display(void)
{
int result;
cout<<"\n\n\n";
result=search();
if(result==-1)
    cout<<"\nEntered Search is Illegal\n";
else
    cout<<"\nSearch is Located at "<<result<<" Position";
}

void main()
{
clrscr();
sel_search o1;
o1.getdata();
o1.display();
getch();
}
 #include<iostream.h>
 #include<conio.h>


 int year_code(int,int);

 main()
    {
       clrscr();

       int date;
       int year;
       int month;
       int birth_week;
       int century;
       int birth_year;
       int century_remainder;
       int century_code;
       int birth_year_code;
       int day;

       cout<<"\n Enter the date in the following pattern :"<<endl;
       gotoxy(34,3);
       cout<<"Date - Month - Year"<<endl;

       gotoxy(39,4);
       cout<<"-       -       "<<endl;

       gotoxy(35,4);
       cin>>date;

       gotoxy(43,4);
       cin>>month;

       gotoxy(50,4);
       cin>>year;

       century=year/100;
       birth_year=year%100;

       century_remainder=century%4;

       if(century_remainder==0)
      century_code=date-1;

       elseif(century_remainder==1)
      century_code=date-3;

       elseif(century_remainder==2)
      century_code=date-5;

       else
      century_code=date;

       birth_year_code=year_code(birth_year,month);
       birth_week=century_code+birth_year_code;

       cout<<"\n The day on the given date is : ";

       day=birth_week%7;

       switch(day)
      {
         case 0: cout<<"Friday";
             break;

         case 1: cout<<"Saturday";
             break;

         case 2: cout<<"Sunday";
             break;

         case 3: cout<<"Monday";
             break;

         case 4: cout<<"Tuesday";
             break;

         case 5: cout<<"Wednesday";
             break;

         case 6: cout<<"Thursday";
             break;
      }

       getch();
       return 0;
    }

int year_code(int year,int month)
    {
       int code;

       int array_1[12]={3,6,6,2,4,7,2,5,1,3,6,1};
       int array_2[12]={4,7,7,3,5,1,3,6,2,4,7,2};
       int array_3[12]={5,1,1,4,6,2,4,7,3,5,1,3};
       int array_4[12]={6,2,3,6,1,4,6,2,5,7,3,5};
       int array_5[12]={1,4,4,7,2,5,7,3,6,1,4,6};
       int array_6[12]={2,5,5,1,3,6,1,4,7,2,5,7};
       int array_7[12]={3,6,6,2,4,7,2,5,1,3,6,1};
       int array_8[12]={4,7,1,4,6,2,4,7,3,5,1,3};
       int array_9[12]={6,2,2,5,7,3,5,1,4,6,2,4};
       int array_10[12]={7,3,3,6,1,4,6,2,5,7,3,5};
       int array_11[12]={2,3,1,2,4,7,2,5,1,3,6,1};
       int array_12[12]={7,3,4,7,2,5,7,3,6,1,4,6};
       int array_13[12]={5,1,2,5,7,3,5,1,4,6,2,4};
       int array_14[12]={3,6,7,3,5,1,3,6,2,4,7,2};
       int array_15[12]={1,4,5,1,3,6,1,4,7,2,5,7};

       if(year==1 || year==29 || year== 57 || year==85 || year==7 ||
     year==35 || year==63 || year==91 || year==18 || year==46 || year==74)
      code=array_1[month-1];

       elseif(year==2 || year==30 || year== 58 || year==86 || year==13 ||
     year==41 || year==69 || year==97 || year==19 || year==47 || year==75)
      code=array_2[month-1];

       elseif(year==3 || year==31 || year== 59 || year==87 || year==14 ||
     year==42 || year==70 || year==98 || year==25 || year==53 || year==81)
      code=array_3[month-1];

       elseif(year==4 || year==32 || year== 60 || year==88)
      code=array_4[month-12];

       elseif(year==5 || year==33 || year== 61 || year==89 || year==11 ||
     year==39 || year==67 || year==95 || year==22 || year==50 || year==78)
      code=array_5[month-1];

       elseif(year==6 || year==34 || year== 62 || year==90 || year==17 ||
             year==45 || year==73 || year==23 || year==51 || year==79)
      code=array_6[month-1];

       elseif(year==7 || year==35 || year== 63 || year==91)
      code=array_7[month-1];

       elseif(year==8 || year==36 || year==64 || year==92)
      code=array_8[month-1];

       elseif(year==9 || year==37 || year== 65 || year==93 || year==15 ||
     year==43 || year==71 || year==99 || year==26 || year==54 || year==82)
      code=array_9[month-1];

       elseif(year==10 || year==38 || year==66 || year==94 || year==21 ||
             year==49 || year==77 || year==27 || year==55 || year==83)
      code=array_10[month-1];

       elseif(year==12 || year==40 || year==68 || year==96)
      code=array_11[month-1];

       elseif(year==16 || year==44 || year==72 || year==100)
      code=array_12[month-1];

       elseif(year==20 || year==48 || year==76)
      code=array_13[month-1];

       elseif(year==24 || year==52 || year==80)
      code=array_14[month-1];

       elseif(year==28 || year==56 || year==84)
      code=array_15[month-1];

       return code;
    }
#include<iostream.h>
#include<iomanip.h>
template<class s>                                ///templats classclass stack
{
      private:
          int top;
          s item;
          s array[5];
      public:
          stack()
          {
              top=-1;
          }
          void getdata()
          {
                  cout<<"enter item to push in stack"<<endl;
                cin>>item;
             
          }
          void push()
          {
              if(top==5)
                  cout<<"overflow"<<endl;
              else
              {
                  top++;
                  array[top]=item;
              }
          }
          void pop()
          {
              if(top==-1)
                  cout<<"underflow"<<endl;
              else
              {
                  array[top]=NULL;
                 
                  top--;
              }
          }
          void disp()
          {
               for(int i=0;i<=top;i++)
               {
                     cout<<array[i]<<'\t';
               }
                cout<<endl;
          }
};
int main()
{
    stack<int>stacki;
    stack<char>stackc;
    int r;
    char ch;
    do
    {
        cout<<"integer array"<<endl;
        cout<<"press 1 to push element in stack & 2 to pop it"<<endl;
        cout<<"    3 to display stack"<<endl;
        cin>>r;
        switch (r)
        {
          case 1:
               stacki.getdata();
               stacki.push();
               break;
          case 2:
                stacki.pop();
                break;
          case 3:
                stacki.disp();
                break;
          default:
            cout<<"bad input"<<endl;
            break;
        }
        cout<<"do you want to process more y/n"<<endl;
        cin>>ch;
    }
    while(ch!='n');
do
{  
    cout<<"character array"<<endl;
        cout<<"press 1 to push element in stack & 2 to pop it"<<endl;
        cout<<"    3 to display stack"<<endl;
        cin>>r;
        switch (r)
        {
          case 1:
               stackc.getdata();
               stackc.push();
               break;
          case 2:
                stackc.pop();
                break;
          case 3:
                stackc.disp();
                break;
          default:
            cout<<"bad input"<<endl;
            break;
        }
        cout<<"do you want to process more y/n"<<endl;
        cin>>ch;
    }
    while(ch!='n');

    return 0;
}