declaration syntax error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samrah
    New Member
    • Jan 2017
    • 3

    declaration syntax error

    i cannot run this program just because of 1 declaration syntax error.
    also there is 1 warning which says"unreachabl e code".
    what to do??
    Code:
    #include<iostream.h>
    #include<stdio.h>
    #include<conio.h>
    #include<iomanip.h>
    #include<process.h>
    int sum=0,sum1=0,sum2=0,l,r,sum3=0;
    void board();
    int checkwin();
    char square[10] = {'o','1','2','3','4','5','6','7','8','9'};
    
    void main()
    {
    clrscr();
    
    void pg3();
    
    pg3();
    
    void pg1();
    
    pg1();
    
    void pg4();
    
    pg4();
    
    
    
    
    
    
    getch();
    
    }
    
    
    void pg3()
    {
    cout<<"\n\n";
    cout<<"\n\t\t@@@@ @@@@ @ @ @@@@ @ @ @@@@@ @@@@ @@@@ \n";
    cout<<"\n\t\t@ @  @ @@ @@ @ @ @ @@ @\n";
    cout<<"\n\t\t@  @ @ @ @ @ @@@ @ @  @ @@@ @@@\n";
    cout<<"\n\t\t@  @ @ @  @ @ @ @ @ @ @ @\n";
    cout<<"\n\t\t@@@@ @@@@ @ @ @ @@@@ @ @@@@ @ @\n\n\n\n\n\n\n\n";
    cout<<"\n\t\t\t\t@@@@ @@@@ @@@@ @@@@@ @@@@ @@@@ @@@@@\n";
    cout<<"\n\t\t\t\t@ @ @ @ @  @ @  @ @ @\n";
    cout<<"\n\t\t\t\t@@@ @@@ @ @ @ @@@ @  @ \n";
    cout<<"\n\t\t\t\t@  @ @ @ @ @@ @ @  @ \n";
    cout<<"\n\t\t\t\t@  @ @ @@@@ @@@ @@@@ @@@@ @ \n\n\n\n\n\n\n";
    cout<<"\n\n\n\n";
    cout<<"\n\t\t\t\tCREATED BY:";
    cout<<"\n\t\t\t\tSAMRAH ZAKI ANSARI XI B";
    cout<<"\n\t\t\t\tPALAK TAKHTANI XI A";
    getch();
    }
    
    void pg1()
    
    {
    clrscr();
    cout<<"\n";
    for(int m=1;m<2;++m)
    {
    for(int n=1;n<=10;++n)
    {
    cout<<"¤";
    }
    cout<<"\n";
    }
    for(m=1;m<8;++m)
    {
    cout<<"¤¤\n";
    }
    cout<<"\n\n\n\t""WELCOME TO WORLD'S LARGEST AMUSEMENT PARK \n\n";
    cout<<"\n\n\n\n\n\n";
    //Program to print heart pattern
     int n,i,j;
     n=20;
     if(n%2==0)
      n++;
     cout<<"\n\n"<<"\tM A G I C  K I N G D O M\n";
     for(i=0;i<n;i++)
     {
      for(j=0;j<n;j++)
      {
       if(i==0&&(j>=n/5&&j<=n/2-n/5)||i==0&&(j>=n/2+n/5&&j<=(n-1)-n/5))
        cout<<"* ";
       else if(i>0&&i<=n/5&&(j==n/5-i||j==n/2+n/5-i||j==n/2-n/5+i||j==(n-1)-n/5+i))
        cout<<"* ";
       else if((i>n/5&&i<=n/2)&&(j==0||j==n-1))
        cout<<"* ";
       else if(i>n/2&&(j==i-n/2||j==(n-1)-(i-n/2)))
        cout<<"* ";
       else cout<<"  ";
      }
      cout<<"\n";
     }
     cout<<"\tM A G I C  K I N G D O M\n";
     getch();
    }
    
    void pg4()
    { clrscr();
    float c,d,e,f,g;
    cout<<"\n\n\n\n";
    cout<<"\t                 ENTRY FEES                       \n";
    cout<<"\t****************************************************\n";
    cout<<"\t|---------------------|---------------------|\n";
    cout<<"\t|               |    PRICES      |\n";
    cout<<"\t|    CRITERIA   |----------------|\n";
    cout<<"\t|              |  CHILDREN  |  ADULTS  |\n";
    cout<<"\t|-----------------|------------|------------|\n";
    cout<<"\t|              |      |        |\n";
    cout<<"\t| HEIGHT BETWEEN 3.5 TO 5 FEET | ?500/- | ?550/- |\n";
    cout<<"\t|              |      |        |\n";
    cout<<"\t| HEIGHT ABOVE 5 FEET  | ?600/- | ?800/- |\n";
    cout<<"\t|              |      |        |\n";
    cout<<"\t| SENIOR CITIZENS (ABOVE 60 YRS) | ?500/- |\n";
    cout<<"\t|              |      |        |\n";
    cout<<"\t|---------------------|---------------------|\n\n\n";
    cout<<"\t               *******************************\n\n";
    cout<<"\t    HURRY !!!!! CHILDREN BELOW 3.5 FEET GET FREE ENTRY!!!!!!!!\n\n";
    cout<<"\t *********************************\n\n";
    
    cout<<"\n ENTER NO.OF CHILDREN BETWEEN HEIGHT 3.5 TO 5 FEET";
    cin>>c;
    cout<<"\n ENTER NO.OF ADULTS BETWEEN HEIGHT 3.5 TO 5 FEET";
    cin>>d;
    cout<<"\n ENTER NO.OF CHILDREN ABOVE HEIGHT 5 FEET";
    cin>>e;
    cout<<"\n ENTER NO.OF ADULTS ABOVE HEIGHT 5 FEET";
    cin>>f;
    cout<<"\n ENTER NO.OF SENIOR CITIZENS";
    cin>>g;
    sum=((c*500)+(d*550)+(e*600)+(f*800)+(g*500));
    
    clrscr();
    
    
    cout<<"\n\n\n";
    for(int l=1;l<4;++l)
    cout<<"\n";
    for(int i=1;i<3;++i)
    {
    for(int j=1;j<81;++j)
    cout<<"¤";
    }
    
    int a;
    cout<<"\n\t\t\t\t\tLIVE THE THRILL \n\n\n\n\n\n\n\n\nENTER INTO THE WORLD OF RIDES\n\n\n\n\n\n\t\t1.LAND PARADISE\n\n\n\n\n\t\t2.WATER PARADISE\n";
    for(int q=1;q<4;++q)
    cout<<"\n";
    for(int h=1;h<3;++h)
    {
    for(int k=1;k<81;++k)
    cout<<"¤";
    }
    cout<<"ENTER YOUR CHOICE (1/2)\n";
    cin>>a;
    switch(a) //land water choice
    {
    case 1:
    {
    clrscr();
    start:
    {
    cout<<"\t        LAND PARADISE\n";
    cout<<"\t      ^^^^^^^^^^^^^^^^^^^^ \n\n";
    cout<<"|-----------------|-------------------|------------------|\n";
    cout<<"| 1.KIDS RIDES    | 2.ADULT RIDES    | 3.FAMILY RIDES    |\n";
    cout<<"|-----------------|-------------------|------------------|\n";
    cout<<"| 1.BIG APPLE RS300/-| 1.SHOT N DROP RS400/-|1.MONSTERS IN MIST RS450/-|\n";
    cout<<"| 2.HAPPY SLEY RS325/-|2.TOP SPIN RS425/-|2.CRAZY CUPS RS475/-|\n";
    cout<<"| 3.           RS350/-|3.ENTERPRISE RS450/-|3.AQUA DRIVE RS500/-|\n";
    cout<<"| 4.CATERPILLAR RS375/-|4.RAINBOW RS475/-|4.PRABAL THE KILLER RS525/-|\n";
    cout<<"| 5.YARD TRAIN RS400/-|5.ZYCLONE RS500/-|5.MIRROR MAZE RS550/-|\n";
    cout<<"| 6.BOAT RIDE RS450/-|6.HOOLA LOOP RS550/-|6.HIGHWAY RS600/-|\n";
    cout<<"|-----------------|-------------------|------------------|\n";
    
    int k,b;
    cout<<"\nENTER YOUR CHOICE \n1.KIDS RIDES\n2.ADULT RIDES\n3.FAMILY RIDES\n";
    cin>>b;
    switch(b)     //land choice
    {
    case 1:
    if(b==1)
    { cout<<"\nCHOOSE YOUR RIDE(1-6)";
    cin>>k;
    switch(k)    //sub choice
    {
    case 1:
    {if(k==1)
    sum1=sum1+300;}
    case 2:
    {if(k==2)
    sum1=sum1+325;}
    case 3:
    {if(k==3)
    sum1=sum1+350;}
    case 4:
    {if(k==4)
    sum1=sum+375;}
    case 5:
    {if(k==5)
    sum1=sum1+400;}
    case 6:
    {if(k==6)
    sum1=sum1+450;}
    } }
    
    case 2:
    if(b==2)
    {
    cout<<"\n CHOOSE YOUR RIDE(1-6)";
    cin>>k;
    switch(k)
    {
    case 1:
    { if(k==1)
    sum1=sum1+400;}
    case 2:
    {if(k==2)
    sum1=sum1+425;}
    case 3:
    { if(k==3)
    sum1=sum1+450;}
    case 4:
    { if(k==4)
    sum1=sum1+475;}
    case 5:
    { if(k==5)
    sum1=sum1+500;}
    case 6:
    { if(k==6)
    sum1=sum+550;}
    }
    }
    
    case 3:
    if(b==3)
    {
    cout<<"\n CHOOSE YOUR RIDE(1-6)";
    cin>>k;
    switch(k)
    {
    case 1:
    {if(k==1)
    sum1=sum1+450;}
    case 2:
    { if(k==2)
    sum1=sum1+475;}
    case 3:
    { if(k==3)
    sum1=sum1+500;}
    case 4:
    { if(k==4)
    sum1=sum1+525;}
    case 5:
    { if(k==5)
    sum1=sum1+550;}
    case 6:
    { if(k==6)
    sum1=sum1+600;}
    }
    } } }
    
    char h;
    cout<<"\n DO YOU WANT TO CONTINUE? PRESS Y OR N";
    cin>>h;
    if(h=='y'||h=='Y')
    goto start;
    
    else
    {
    cout<<"\n PRESS 1 TO ENTER FOOD ZONE\n PRESS 2 TO ENTER WATER PARADISE\n PRESS 3 TO EXIT\n";
    cin>>r;
    if(r==1)
    {
    starter:
    {
    cout<<"\n\n\n";
    cout<<"  \t\t   SNACK ZONE         \n";
    cout<<"\t\t#################################\n\n\n";
    cout<<"\t\t1.FRENCH FRIES\t\tRS40/-\n\t\t2.VEG KOTHE\t\t\tRS60/-\n\t\t3.PASTA\t\t\tRS85/-\n\t\t\t4.GRILLED SANDWICH\t\tRS90/-\n\t\t\t5.VEG CUTLET\t\t\tRS50/-\n\t\t6.COFFEE/TEA\t\t\tRS55/-\n\t\t\t7.PIZZA\t\t\tRS150/-\n";
    cout<<"\n WHAT WOULD YOU LIKE TO HAVE?";
    cout<<"\n ENTER THE CODE TO PLACE YOUR ORDER";
    cin>>l;
    char t;
    cout<<"WOULD YOU LIKE TO PLAY A GAME OF TIC TAC TOE WHILE YOU WAIT FOR YOUR BILL??(Y/N)";
    cin>>t;
    if((t=='y')||(t=='Y'))
    goto tictactoe;
    else
    {
     summation:
    switch(l)
    {
    case 1:
    { if(l==1)
    sum2=sum2+40;}
    case 2:
    { if(l==2)
    sum2=sum2+60;}
    case 3:
    { if(l==3)
    sum2=sum2+85;}
    case 4:
    { if(l==4)
    sum2=sum2+90;}
    case 5:
    { if(l==5)
    sum2=sum2+50;}
    case 6:
    { if(l==6)
    sum2=sum2+55;}
    case 7:
    { if(l==7)
    sum2=sum2+150;}
    } }
    
    char m;
    cout<<"\nWANT TO CONTINUE";
    cin>>m;
    if(m=='y'||m=='Y')
    goto starter;
    else
    { cout<<"\n THANKS FOR VISITING US";
    cout<<"\n\nPRESS ANY KEY TO REACH BILLING COUNTER";
    getch();
    
    bill:
    {
    clrscr();
    cout<<"\n\n\n";
    cout<<"\t|-------------------------------------------------|\n";
    cout<<"\t|                   BILL                          |\n";
    cout<<"\t|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n";
    cout<<"\t|-----------------------|-------------------------|\n";
    cout<<"\t|  CRITERIA             |        TOTAL AMOUNT     |\n";
    cout<<"\t|                       |                         |\n";
    cout<<"\t|-----------------------|-------------------------|\n";
    cout<<"\t|  ENTRY FEES           |"<<setw(6)<<sum<<"       |\n";
    cout<<"\t|                       |                         |\n";
    cout<<"\t| PRICES FOR RIDES      |"<<setw(6)<<sum1+sum3<< "|\n";
    cout<<"\t|                       |                         |\n";
    cout<<"\t| PRICES FOR FOOD       |"<<setw(6)<<sum2<<";     |\n";
    cout<<"\t|                       |                         |\n";
    cout<<"\t|-----------------------|-------------------------|\n";
    cout<<"\t|                       |                         |\n";
    cout<<"\t| NET PRICE             |"<<setw(6)<<sum+sum1+sum2+sum3<<"|\n";
    cout<<"\t|               |                |\n";
    cout<<"\t|-------------------|----------------------------------|\n";
    
    
    cout<<"\t ####################################################\n";
    cout<<"\n\n\n\n";
    cout<<"\t       THANKS FOR VISITING \n";
    cout<<"\t           HAVE A NICE DAY \n";
    cout<<"\n\n\n\n";
    cout<<"\t ####################################################\n";
    
    getch();
    exit(0);
    } } }
    
    if(r==2)
    {
    water:
    {
    
    int s,t;
    cout<<"\n\n\n\n";
    cout<<"\t\t          WATER PARADISE \n";
    cout<<"\t\t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n";
    cout<<"\t\t|---------------------|----------------------|\n";
    cout<<"\t\t|   KIDS SLIDES       |   ADULT SLIDES       |\n";
    cout<<"\t\t|---------------------|----------------------|\n";
    cout<<"\t\t| 1.JUST SLIDES       | 1.WATER OVERLOAD     |\n";
    cout<<"\t\t|---------------------|----------------------|\n";
    cout<<"\t\t| 2.MAZE OF SLIDES    | 2.DISCO SLIDES       |\n";
    cout<<"\t\t|---------------------|----------------------|\n";
    cout<<"\t\t| 3.WATER BUCKETS     | 3.CRAZY WATER        |\n";
    cout<<"\t\t|---------------------|----------------------|\n";
    
    cout<<"\n\t\tENTER CHOICE\n\n\t1.KIDS SLIDES\n\t2.ADULT SLIDES\n";
    cin>>s;
    switch(s)
    {
    case 1:
    { cout<<"\n CHOOSE YOUR SLIDE(1-3)\n";
    cin>>t;
    if(t==1)
    sum3=sum3+600;
    if(t==2)
    sum3=sum3+650;
    if(t==3)
    sum3=sum3+700;
    }
    
    case 2:
    { cout<<"\nCHOOSE YOUR SLIDE(1-3)\n";
    cin>>t;
    if(t==1)
    sum3=sum3+700;
    if(t==2)
    sum3=sum3+750;
    if(t==3)
    sum3=sum3+800;
    }
    getch();}
    } } }
    
    char u; int v;
    cout<<"\nWANT TO CONTINUE?\n";
    cin>>u;
    if(u=='y'||u=='Y')
    goto water;
    else
    {
    cout<<"\nPRESS\n\n\t1.LAND SLIDES\n\t2.FOOD ZONE\n\t3.EXIT\n";
    cin>>v;
     switch(v)
    {
    case 1:
    goto start;
    case 2:
    goto starter;
    case 3:
    goto bill;
    } } }
    case 2:
    goto water;
    }
    
    if(r==3)
    {cout<<"\n\nPRESS ANY KEY TO REACH BILLING COUNTER";
    goto bill;
    }
    getch();
     //tic tac toe game
    tictactoe:
    {
    int player = 1,z,choice;
    char mark;
    do{
    board();
    player=(player%2)?1:2;
    cout << "Player " << player << ", enter a number:  ";
    cin >> choice;
    mark=(player == 1) ? 'X' : 'O';
    if (choice == 1 && square[1] == '1')
    square[1] = mark;
    else if (choice == 2 && square[2] == '2')
    square[2] = mark;
    else if (choice == 3 && square[3] == '3')
    square[3] = mark;
    else if (choice == 4 && square[4] == '4')
    square[4] = mark;
    else if (choice == 5 && square[5] == '5')
    square[5] = mark;
    else if (choice == 6 && square[6] == '6')
    square[6] = mark;
    else if (choice == 7 && square[7] == '7')
    square[7] = mark;
    else if (choice == 8 && square[8] == '8')
    square[8] = mark;
    else if (choice == 9 && square[9] == '9')
    square[9] = mark;
    else
    {cout<<"Invalid move ";
    player--;
    cin.ignore();
    cin.get();
    }
    z=checkwin();
    player++;
    }while(z==-1);
    board();
    if(z==1)
    
    cout<<"==>\aPlayer "<<--player<<" win ";
    else
    cout<<"==>\aGame draw";
    cin.ignore();
    cin.get();
    goto  summation;
    }
    
    /*********************************************
    
    	FUNCTION TO RETURN GAME STATUS
    	1 FOR GAME IS OVER WITH RESULT
    	-1 FOR GAME IS IN PROGRESS
    	O GAME IS OVER AND NO RESULT
    **********************************************/
    
    int checkwin()
    {
    	if (square[1] == square[2] && square[2] == square[3])
    
    		return 1;
    	else if (square[4] == square[5] && square[5] == square[6])
    
    		return 1;
    	else if (square[7] == square[8] && square[8] == square[9])
    
    		return 1;
    	else if (square[1] == square[4] && square[4] == square[7])
    
    		return 1;
    	else if (square[2] == square[5] && square[5] == square[8])
    
    		return 1;
    	else if (square[3] == square[6] && square[6] == square[9])
    
    		return 1;
    	else if (square[1] == square[5] && square[5] == square[9])
    
    		return 1;
    	else if (square[3] == square[5] && square[5] == square[7])
    
    		return 1;
    	else if (square[1] != '1' && square[2] != '2' && square[3] != '3'
    		    && square[4] != '4' && square[5] != '5' && square[6] != '6'
    		  && square[7] != '7' && square[8] != '8' && square[9] != '9')
    
    		return 0;
    	else
    		return -1;
    }
    
    
    /*******************************************************************
         FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK
    ********************************************************************/
    
    
    void board()
    {
    	clrscr();
    	cout << "\n\n\tTic Tac Toe\n\n";
    
    	cout << "Player 1 (X)  -  Player 2 (O)" << endl << endl;
    	cout << endl;
    
    	cout << "     |     |     " << endl;
    	cout << "  " << square[1] << "  |  " << square[2] << "  |  " << square[3] << endl;
    
    	cout << "_____|_____|_____" <<endl;
    	cout << "     |     |     " << endl;
    
    	cout << "  " << square[4] << "  |  " << square[5] << "  |  " << square[6] << endl;
    
    	cout << "_____|_____|_____" << endl;
    	cout << "     |     |     " << endl;
    
    	cout << "  " << square[7] << "  |  " << square[8] << "  |  " << square[9] << endl;
    
    	cout << "     |     |     " << endl << endl;
    };
    }}
    unreachable code warning is at line 435
    declaration syntax error is at line 497 or 498.
    Last edited by samrah; Jan 7 '17, 02:36 AM. Reason: missed a line
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    When you call a function you don't use the return type. Just remove the void inside main();

    Comment

    • samrah
      New Member
      • Jan 2017
      • 3

      #3
      I'm sorry I didn't get what you told me to do.Can you explain it please?

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        You call a function by:

        Code:
        pg3();
        and not by:

        Code:
        void pg3();
        void pg3(); is a function prototype. You can't use it for both a prototype and a call. The compiler won't allow it.

        Comment

        • samrah
          New Member
          • Jan 2017
          • 3

          #5
          void pg3();
          is where i am defining the function and
          pg3();
          is where i'm calling it.
          moreover the error is on line 498.
          so please help.i've to submit my project in 3 days.

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            I am not able to compile your code from your first post because of problems with mis-matched or missing braces.

            You need to compile the code and fix the first error. Then re-compile. Many errors go away when you do this.

            Do you have more recent code?

            Comment

            Working...