it keeps on saying '{' token error.
did I put something wrong that the program keeps on saying '{' token error?

#include <stdio.h>
#include <math.h>
int Calendar(int daycode,int year,int leapyear);

 void dec_bin(int bin)

					{
						int x, y;
						x = y = 0;

						for(y = 7; y >= 0; y--)
							{
							x = bin / (1 << y);
							bin = bin - x * (1 << y);
							printf("%d", x);
							}
							printf("\n");

				}
int main()
{
	int year;
	int daycode;
	int leapyear;
	int month;
	int skip;
	int day;
	int daysinmonth;
	double a;
	double b;
	double c;
	double angleB;
	double angleA;
	double angleC;
	double PI=3.14159265;
	int m1[5][5],i,j,k,m2[5][5],mult[5][5],r1,c1,r2,c2;
	int x;
	char z;

menu:

printf("***********************************");
printf("\n		  ~* M E N U *~\n");
printf("***********************************");
printf("\n\n 1: Multiplication of two matrices.\n\n");
printf(" 2: Solving Triangle using Sine Law.\n\n");
printf(" 3: Table Dec, Hex, Oct and Bin.\n\n");
printf(" 4: Calendar Program.\n\n");
printf(" 5: End Program.\n\n");
printf("***********************************\n\n\n");
printf("choice:");

scanf("%d",&x);
if (x==1)
{
  {
Matrix:

	printf("Enter number of rows and columns of first matrix MAX 5\n");
	scanf("%d%d",&r1,&c1);
	printf("Enter number of rows and columns of second matrix MAX 5\n");
	scanf("%d%d",&r2,&c2);
	if(c1=r2)
	{
		printf("Enter rows and columns of First matrix \n");
		printf("Row wise\n");
		for(i=0;i<r1;i++)
		{
			for(j=0;j<c1;j++)
				scanf("%d",&m1[i][j]);
		}
		printf("You have entered the first matrix as follows:\n");
		for(i=0;i<r1;i++)
		{
			for(j=0;j<c1;j++)
				printf("%d\t",m1[i][j]);
			printf("\n");
		}
		printf("Enter rows and columns of Second matrix \n");
		printf("Again row wise\n");
		for(i=0;i<r2;i++)
		{
			for(j=0;j<c2;j++)
				scanf("%d",&m2[i][j]);
		}
		printf("You have entered the second matrix as follows:\n");
		for(i=0;i<r2;i++)
		{
			for(j=0;j<c2;j++)
				printf("%d\t",m2[i][j]);
			printf("\n");
		}
		printf("********************************************\n\n");
		printf("Now we multiply both the above matrix \n");
		printf("The result of the multiplication is as follows:\n");

		for(i=0;i<r1;i++)
		{
			for(j=0;j<c2;j++)
			{
				mult[i][j]=0;
				for(k=0;k<c1;k++)
				{
				mult[i][j]=mult[i][j]+m1[i][k]*m2[k][j];
				}
				printf("%d\t",mult[i][j]);
			}
			printf("\n");
		}

	}
	else
	{
		printf("Matrix multiplication cannot be done");
	}
  }

	again:

	printf("\n\nDo you want to try again?[y/n]:");
	scanf("%s",&z);
	if ((z=='y')||(z=='Y'))
		{
		goto Matrix;
		}
	else if ((z=='n')||(z=='N'))
		{
		goto menu;
		}
	else
		{
		printf("invalid choice");
		goto again;
		}
}
else if (x==2)
		{
			{
			Sine:

			printf("Solving a triangle and calculating it's angle\n\n");
			printf("\n\nEnter the side length of A:");
			scanf("%lf",&angleA);
			printf("\n\nEnter the side length of B:");
			scanf("%lf",&angleB);
			printf("\n\nEnter the size of the angle of a:");
			scanf("%lf",&a);


			angleC = 180-(angleA+angleB);
			b = (a*(sin(angleB*PI/180)))/((sin(angleA*PI/180)));
			c = (a*(sin(angleC*PI/180)))/((sin(angleA*PI/180)));


			printf("\nThe side length of b is:%lf",b);
			printf("\nThe side length of c is:%lf",c);
			printf("\nThe angle of C is:%lf",angleC);
			}

			again1:

			printf("\n\nDo you want to try again?[y/n]:");
			scanf("%s",&z);
			if ((z=='y')||(z=='Y'))
				{
				goto Sine;
				}
			else if ((z=='n')||(z=='N'))
				{
				goto menu;
				}
			else
				{
				printf("invalid choice");
				goto again1;
				}

		}
else if (x==3)



{
	{

					table:

						{


						int count;
						printf("\n\n\nConversion table - Decimal, Hexadecimal, Octal, Binary\n\n");
						printf("Dec\tHex\tOct\tBin\n");
						printf("----------------------------------\n");
						for (count = 0; count <=256; count=count +1)
							{
							printf("%d  \t%x   \t%o\t",count, count, count);
							dec_bin(count);
							}
						}
	}
		again2:

			printf("\n\nDo you want to try again?[y/n]:");
			scanf("%s",&z);
			if ((z=='y')||(z=='Y'))
				{
				goto table;
				}
			else if ((z=='n')||(z=='N'))
				{
				goto menu;
				}
			else
				{
				printf("invalid choice");
				goto again2;
				}
}
else if (x==4)
{
	calendar:


{

printf(" \n~* Calendar Program *~\n");
printf("--------------------------\n\n\n");
printf("Enter a year:");
scanf("%d",&year);
{

leapyear=(!(year%4)&&(year%100))||!(year%4);
daycode=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7;
Calendar(daycode,year,leapyear);
}
}
int Calendar(int daycode,int year,int leapyear)
{


for(month=1;month<=12;month++)
{
skip=0;
day=1;
if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)
   daysinmonth=31;
else if(month==4||month==6||month==9||month==11)
	 daysinmonth=30;
	 else if(month==2)
	  if(leapyear==1)
	  daysinmonth=29;
	  else if(leapyear==0)
		   daysinmonth=28;
		   printf("\n***************************");

switch(month)
{
case 1: printf("\n\n\t%d\n\nJANUARY			   %d",year,year);break;
case 2: printf("\nFEBRUARY			  %d",year);break;
case 3: printf("\nMARCH				 %d",year);break;
case 4: printf("\nAPRIL				 %d",year);break;
case 5: printf("\nMAY				   %d",year);break;
case 6: printf("\nJUNE				  %d",year);break;
case 7: printf("\nJULY				  %d",year);break;
case 8: printf("\nAUGUST				%d",year);break;
case 9: printf("\nSEPTEMBER			 %d",year);break;
case 10: printf("\nOCTOBER			   %d",year);break;
case 11: printf("\nNOVEMBER			  %d",year);break;
case 12: printf("\nDECEMBER			  %d",year);break;

}
printf ("\nSUN MON TUE WED THU FRI SAT\n");

while(day<=daysinmonth)
{
  while(day<=daysinmonth)
  {
	  while(skip<daycode)
	  {
	printf("	");
	skip=skip+1;
	  }
	  printf("%2d  ",day);
	  day=day+1;
	  if(((day+daycode)%7)==1)
	  {
	printf("\n");
	  }
  }
}
daycode=(daycode+daysinmonth)%7;
}
}
again3:

	printf("\n\nDo you want to try again?[y/n]:");
	scanf("%s",&z);
	if ((z=='y')||(z=='Y'))
		{
		goto calendar;
		}
	else if ((z=='n')||(z=='N'))
		{
		goto menu;
		}
	else
		{
		printf("invalid choice");
		goto again3;
		}

}
else if (x==5)
{
goto exit;


exit:

return (0);
}
else

{
printf("invalid choice\n\n");

goto menu;

}
}

no... i just deleted it.
but please help me solve the token error problem??

I don't know if this will resolve the problem but you need to put your calendar function outside of the main function. Put your function after the terminating } of the main(). See if that helps.
Also you have two braces after if/else in other spots two. If those are unnecessary, you should delete them as well.

Edited 7 Years Ago by Grn Xtrm: n/a

I tried to call it but it gives me another error.
this error

undefined reference to `Calendar(int, int, int)'
undefined reference to `Calendar(int, int, int)'
=== Build finished: 2 errors, 0 warnings ===

#include <stdio.h>
#include <math.h>
int Calendar(int daycode,int year,int leapyear);

 void dec_bin(int bin)

                    {
                        int x, y;
                        x = y = 0;

                        for(y = 7; y >= 0; y--)
                            {
                            x = bin / (1 << y);
                            bin = bin - x * (1 << y);
                            printf("%d", x);
                            }
                            printf("\n");

                }
int main()
{
    int year;
    int daycode;
    int leapyear;
    int month;
    int skip;
    int day;
    int daysinmonth;
    double a;
    double b;
    double c;
    double angleB;
    double angleA;
    double angleC;
    double PI=3.14159265;
    int m1[5][5],i,j,k,m2[5][5],mult[5][5],r1,c1,r2,c2;
    int x;
    char z;

menu:

printf("***********************************");
printf("\n          ~* M E N U *~\n");
printf("***********************************");
printf("\n\n 1: Multiplication of two matrices.\n\n");
printf(" 2: Solving Triangle using Sine Law.\n\n");
printf(" 3: Table Dec, Hex, Oct and Bin.\n\n");
printf(" 4: Calendar Program.\n\n");
printf(" 5: End Program.\n\n");
printf("***********************************\n\n\n");
printf("choice:");

scanf("%d",&x);
if (x==1)
{
  {
Matrix:

    printf("Enter number of rows and columns of first matrix MAX 5\n");
    scanf("%d%d",&r1,&c1);
    printf("Enter number of rows and columns of second matrix MAX 5\n");
    scanf("%d%d",&r2,&c2);
    if(c1=r2)
    {
        printf("Enter rows and columns of First matrix \n");
        printf("Row wise\n");
        for(i=0;i<r1;i++)
        {
            for(j=0;j<c1;j++)
                scanf("%d",&m1[i][j]);
        }
        printf("You have entered the first matrix as follows:\n");
        for(i=0;i<r1;i++)
        {
            for(j=0;j<c1;j++)
                printf("%d\t",m1[i][j]);
            printf("\n");
        }
        printf("Enter rows and columns of Second matrix \n");
        printf("Again row wise\n");
        for(i=0;i<r2;i++)
        {
            for(j=0;j<c2;j++)
                scanf("%d",&m2[i][j]);
        }
        printf("You have entered the second matrix as follows:\n");
        for(i=0;i<r2;i++)
        {
            for(j=0;j<c2;j++)
                printf("%d\t",m2[i][j]);
            printf("\n");
        }
        printf("********************************************\n\n");
        printf("Now we multiply both the above matrix \n");
        printf("The result of the multiplication is as follows:\n");

        for(i=0;i<r1;i++)
        {
            for(j=0;j<c2;j++)
            {
            mult[i][j]=0;
            for(k=0;k<c1;k++)
            {
            mult[i][j]=mult[i][j]+m1[i][k]*m2[k][j];
            }
            printf("%d\t",mult[i][j]);
            }
            printf("\n");
        }

    }
    else
    {
        printf("Matrix multiplication cannot be done");
    }
  }

    again:

    printf("\n\nDo you want to try again?[y/n]:");
    scanf("%s",&z);
    if ((z=='y')||(z=='Y'))
        {
        goto Matrix;
        }
    else if ((z=='n')||(z=='N'))
        {
        goto menu;
        }
    else
        {
        printf("invalid choice");
        goto again;
        }
}
else if (x==2)
        {
            {
            Sine:

                printf("Solving a triangle and calculating it's angle\n\n");
                printf("\n\nEnter the side length of A:");
                scanf("%lf",&angleA);
                printf("\n\nEnter the side length of B:");
                scanf("%lf",&angleB);
                printf("\n\nEnter the size of the angle of a:");
                scanf("%lf",&a);


            angleC = 180-(angleA+angleB);
                b = (a*(sin(angleB*PI/180)))/((sin(angleA*PI/180)));
                c = (a*(sin(angleC*PI/180)))/((sin(angleA*PI/180)));


                printf("\nThe side length of b is:%lf",b);
                printf("\nThe side length of c is:%lf",c);
                printf("\nThe angle of C is:%lf",angleC);
            }

            again1:

            printf("\n\nDo you want to try again?[y/n]:");
            scanf("%s",&z);
            if ((z=='y')||(z=='Y'))
                {
                goto Sine;
                }
            else if ((z=='n')||(z=='N'))
                {
                goto menu;
                }
            else
                {
                printf("invalid choice");
                goto again1;
                }

        }
else if (x==3)



{
    {

                    table:

                        {


                        int count;
                        printf("\n\n\nConversion table - Decimal, Hexadecimal, Octal, Binary\n\n");
                        printf("Dec\tHex\tOct\tBin\n");
                        printf("----------------------------------\n");
                        for (count = 0; count <=256; count=count +1)
                            {
                            printf("%d  \t%x   \t%o\t",count, count, count);
                            dec_bin(count);
                            }
                        }
    }
        again2:

            printf("\n\nDo you want to try again?[y/n]:");
            scanf("%s",&z);
            if ((z=='y')||(z=='Y'))
                {
                goto table;
                }
            else if ((z=='n')||(z=='N'))
                {
                goto menu;
                }
            else
                {
                printf("invalid choice");
                goto again2;
                }
}
else if (x==4)
{
    calendar:


{

printf(" \n~* Calendar Program *~\n");
printf("--------------------------\n\n\n");

for(year=1994;year<=1999;year=year+1)
{

leapyear=(!(year%4)&&(year%100))||!(year%4);
daycode=((year-1)*365+((year-1)/4)-((year-1)/100)+((year-1)/400)+1)%7;
Calendar(daycode,year,leapyear);
}
}

{
Calendar(daycode,year,leapyear);
for(month=1;month<=12;month++)
{
skip=0;
day=1;
if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)
   daysinmonth=31;
else if(month==4||month==6||month==9||month==11)
     daysinmonth=30;
     else if(month==2)
      if(leapyear==1)
      daysinmonth=29;
      else if(leapyear==0)
           daysinmonth=28;
           printf("\n***************************");

switch(month)
{
case 1: printf("\n\n\t%d\n\nJANUARY               %d",year,year);break;
case 2: printf("\nFEBRUARY              %d",year);break;
case 3: printf("\nMARCH                 %d",year);break;
case 4: printf("\nAPRIL                 %d",year);break;
case 5: printf("\nMAY                   %d",year);break;
case 6: printf("\nJUNE                  %d",year);break;
case 7: printf("\nJULY                  %d",year);break;
case 8: printf("\nAUGUST                %d",year);break;
case 9: printf("\nSEPTEMBER             %d",year);break;
case 10: printf("\nOCTOBER               %d",year);break;
case 11: printf("\nNOVEMBER              %d",year);break;
case 12: printf("\nDECEMBER              %d",year);break;

}
printf ("\nSUN MON TUE WED THU FRI SAT\n");

while(day<=daysinmonth)
{
  while(day<=daysinmonth)
  {
      while(skip<daycode)
      {
    printf("    ");
    skip=skip+1;
      }
      printf("%2d  ",day);
      day=day+1;
      if(((day+daycode)%7)==1)
      {
    printf("\n");
      }
  }
}
daycode=(daycode+daysinmonth)%7;
}
}
again3:

    printf("\n\nDo you want to try again?[y/n]:");
    scanf("%s",&z);
    if ((z=='y')||(z=='Y'))
        {
        goto calendar;
        }
    else if ((z=='n')||(z=='N'))
        {
        goto menu;
        }
    else
        {
        printf("invalid choice");
        goto again3;
        }

}
else if (x==5)
{
goto exit;


exit:

return (0);
}
else

{
printf("invalid choice\n\n");

goto menu;

}
}

i deleted this

int Calendar(int daycode,int year,int leapyear)

and put the int month and the other int to the top.

from this

int Calendar(int daycode,int year,int leapyear)
{
int month;
int skip;
int day;
int daysinmonth;


for(month=1;month<=12;month++)
{
skip=0;
day=1;
if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)
   daysinmonth=31;
else if(month==4||month==6||month==9||month==11)
     daysinmonth=30;

btw I was trying to call it.

Where is the function definition in your code? That second snippet should be included in the first as a function definition and I'm not seeing it there. Also you didnt close your function in that second snippet.

weeeeeeeee I just solve it.( :
thanks for the help people.

This question has already been answered. Start a new discussion instead.