Declaration Terminated Incorrectly in my code

  • (2 Pages)
  • +
  • 1
  • 2

24 Replies - 1408 Views - Last Post: 16 May 2010 - 03:38 PM Rate Topic: -----

#16 Darkness within  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 11
  • Joined: 16-May 10

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 11:00 AM

View PostKYA, on 16 May 2010 - 09:58 AM, said:

Like we have said, make it possible to digest and we'll be happy to look at it. Until then no.

ok on it
Was This Post Helpful? 0
  • +
  • -

#17 Darkness within  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 11
  • Joined: 16-May 10

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 11:46 AM

couldnt do it ,, some explaining will be gd to use !!
Was This Post Helpful? 0
  • +
  • -

#18 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 990
  • Joined: 30-July 08

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 12:38 PM

*
POPULAR

You should take a look and indenting! Like most people here has said.
This is not indenting:
void main()
{
int i,j,x,sum=0,rat=0,s=0,f=0,q,summ=0,p,r,t,m,n,tm;
int ku[10][10],mrtran[10][10];
void matrix_array(int rat,int ku[10][10],int sum);
void symmetric_call(int sm,int ku[10][10],int tm,int rat);
void transitive_call(int mrtran[10][10],int rat,int f,int x);
/* the rest of code */
}


This is indenting:
void main()
{
    int i,j,x,sum=0,rat=0,s=0,f=0,q,summ=0,p,r,t,m,n,tm;
    int ku[10][10],mrtran[10][10];
    void matrix_array(int rat,int ku[10][10],int sum);
    void symmetric_call(int sm,int ku[10][10],int tm,int rat);
    void transitive_call(int mrtran[10][10],int rat,int f,int x);
/* some other code */

    void matrix_array(int rat,int ku[10][10],int sum)
    {
        int m,n,i,j;
        if(m==n)
        {
            for(i=0;i<m;i++)
            sum+=ku[i][i];
            if(sum==m)
                printf("\n\n **matrix is reflexive**");
            rat+=1;
        }
        if(sum==0)
            printf("\n\n **matrix is ireflexive**");
        if(sum!=m && sum!=0)
            printf("\n\n_the matrix is not reflexive and not ireflexive__");
    }
/* The rest of the code */
}

As you can see, it's possible to read the code now. And this is not a understandable variable name
int q; // Wtf is this for?
This is a understandable variable name
int numbersOfCubes = 0; 
// OH! This one hold the number of cubes created!

To answer your questions How do I indent?!?!?!, press the TAB-button. It looks like this:
Posted Image

This post has been edited by FrozenSnake: 16 May 2010 - 12:39 PM

Was This Post Helpful? 11
  • +
  • -

#19 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3089
  • View blog
  • Posts: 19,137
  • Joined: 14-September 07

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 12:50 PM

rep++ for the image
Was This Post Helpful? 1
  • +
  • -

#20 Darkness within  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 11
  • Joined: 16-May 10

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 02:08 PM

View PostFrozenSnake, on 16 May 2010 - 11:38 AM, said:

You should take a look and indenting! Like most people here has said.
This is not indenting:
void main()
{
int i,j,x,sum=0,rat=0,s=0,f=0,q,summ=0,p,r,t,m,n,tm;
int ku[10][10],mrtran[10][10];
void matrix_array(int rat,int ku[10][10],int sum);
void symmetric_call(int sm,int ku[10][10],int tm,int rat);
void transitive_call(int mrtran[10][10],int rat,int f,int x);
/* the rest of code */
}


This is indenting:
void main()
{
    int i,j,x,sum=0,rat=0,s=0,f=0,q,summ=0,p,r,t,m,n,tm;
    int ku[10][10],mrtran[10][10];
    void matrix_array(int rat,int ku[10][10],int sum);
    void symmetric_call(int sm,int ku[10][10],int tm,int rat);
    void transitive_call(int mrtran[10][10],int rat,int f,int x);
/* some other code */

    void matrix_array(int rat,int ku[10][10],int sum)
    {
        int m,n,i,j;
        if(m==n)
        {
            for(i=0;i<m;i++)
            sum+=ku[i][i];
            if(sum==m)
                printf("\n\n **matrix is reflexive**");
            rat+=1;
        }
        if(sum==0)
            printf("\n\n **matrix is ireflexive**");
        if(sum!=m && sum!=0)
            printf("\n\n_the matrix is not reflexive and not ireflexive__");
    }
/* The rest of the code */
}

As you can see, it's possible to read the code now. And this is not a understandable variable name
int q; // Wtf is this for?
This is a understandable variable name
int numbersOfCubes = 0; 
// OH! This one hold the number of cubes created!

To answer your questions How do I indent?!?!?!, press the TAB-button. It looks like this:
Posted Image


#include<stdio.h>
void matrix_array(int rat,int ku[10][10],int sum);
void symmetric_call(int s,int ku[10][10],int tm,int rat);
void transitive_call(int mrtran[10][10],int rat,int f,int x);
void relation_call(int summ,int s,int f,int rat);
void function_call(int q,int t,int summ,int r,int ku[10][10]);
	void main()
{
int i,j,x,sum=0,rat=0,s=0,f=0,q,summ=0,p,r,t,m,n,tm;
int ku[10][10],mrtran[10][10];
printf("\n enter m=:");
scanf("%d",&m);
printf("\n enter n=:");
scanf("%d",&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{printf("enter ku[%d][%d]",i,j);
scanf("%d",&ku[i][j]);}
for(i=0;i<m;i++)
{for(j=0;j<n;j++)
printf("%d",ku[i][j]);
printf("\n");
}
matrix_array(rat,ku,sum);
symmetric_call(s,ku,tm,rat);
transitive_call(mrtran,rat,f,x);
relation_call(sum,s,f,rat);
function_call(q,t,summ,r,ku);
}
//******************************************************
void matrix_array(int rat,int ku[10][10],int sum)
{
	int m,n,i,j;
	if(m==n)
   {
			for(i=0;i<m;i++)
			sum+=ku[i][i];
         if(sum==m)
         {
         	printf("\n\n **matrix is reflexive**");
		rat+=1;
}
if(sum==0)
	printf("\n\n **matrix is  ireflexive**");
if (sum!=m && sum!=0)
	printf("\n\n___the matrix is not reflexive and not ireflexive__");
}
//**********************************************************
void symmetric_call(int s,int ku[10][10],int tm,int rat)
{
			int s,tm,i,j,m;
			for(i=0;i<m;i++)
         for(j=0;j<n;j++)
         if(i!=j)

         	{
					if(ku[i][j]!=ku[i][j])
					s=1;
               }
							{
                     if(s!=1)
						printf("\n\n**matrix is symmetric**");
						else
						printf("\n\n*_*matrix is not symmetric*_*");
                  }

						for(i=0;i<m;i++)
							for(j=0;j<n;j++)
						   if(i!=j)

{
if((ku[i][j]!=ku[j][i])||(ku[i][j]==0&&ku[j][i]==0))
tm+=1;
}
if(tm==(m*n)-m)
						{
                  printf("\n\n**matrix is antisymmetric**");
							rat+=1;

                  else
                  printf("\n\n*_*matrix is not antisymmetric*_*");
							}
//****************************************************************
void transitive_call(int mrtran[10][10],int rat,int f,int x)
				{
				int i,j,m;
					for(i=0;i<m;i++)
					for(j=0;j<n;j++)
               }

            {
				for(x=0;x<n;x++)
				mrtran[i][j]=mrtran[i][j]+ku[i][x]*ku[x][j];
            if(mrtran[i][j]>1)
				mrtran[i][j]=1;
            }
               {
            	for(i=0;i<m;i++)
					for(j=0;j<n;j++)
						if(mrtran[i][j]>ku[i][j])
						f=1;
						if(f!=1)
               printf("\n\n**matrix is transitive**");
					rat+=1;}
		{
		else
		printf("\n\n*_*matrix is not transitive*_*");
      }
// **************************************
{
	void relation_call(int sum,int s,int f,int rat)
   }

{
int m;
if((sum==m)&&(s!=1)&&(f!=1))
printf("\n\n**ku is an equivalence relation**\n");
else
printf("\n\n*_*ku is not an equivalence relation*_*");
if(rat==3)
printf("\n\n**partial ordering relation**");
else
printf("\n\n*_*not partial ordrring relation*_*");
}
//****************************************************************
void function_call(int p,int tm,int summ,int r,int ku[10][10])
		{
			int i,j,m,n,p;
			p=0;
			for(i=0;i<m;i++)
         }

						{
                  summ=0;
							for(j=0;j<n;j++)
						summ+=ku[i][j];
						if(summ==1)
							p+=1;
						}
									{
                           if(p==m)
					printf("\n\n***ku is function***");
               				}
{
p=0;
t=0;
for(i=0;i<m;i++);
}

			{
				r=0;
				for(j=0;j<n;j++)
					r=r+ku[j][i];
				if(r>=1)
					p+=1;
				if(r==0||r==1)
				t+=1;}
				  {
              	if(p==n)
				printf("\n ku is onto");
				else
			printf("\n ku is not onto");
					if(t==n)
			printf("\n ku is 1-1");
				else
			printf("\n mr is not 1-1");
							else
			printf("\n\n*_is not a function_*");
         }


now is it gd enough to look at
Was This Post Helpful? 0
  • +
  • -

#21 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3089
  • View blog
  • Posts: 19,137
  • Joined: 14-September 07

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 02:25 PM

Until your code compiles cleanly and you tell us what the purpose of this code is, we can't really help you do anything.


Gathering a little context, it appears you are dealing with matrices.



However, there are brackets everywhere, you have C++ style comments in there for some reason, so on and so forth. It's an abomination.
Was This Post Helpful? 0
  • +
  • -

#22 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 990
  • Joined: 30-July 08

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 02:26 PM

You should intend ALL code, and do not OVER intended it then you make it hard to read again, 1 tab per { is enough
int main()
{
    int someVariable;
    if(someVariable == 0)
    {
        if(true)
	    return 1; // Good
    }
    if(someVariable == 0)
    {
	if(true)
	                return 1; // bad
    }
}


I have been kind enough (one time thing!!!!) to intend your code (NOT FIXING IT).
#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j,x,sum=0,rat=0,s=0,f=0,q,summ=0,p,r,t,m,n,tm;
    int ku[10][10],mrtran[10][10];
    void matrix_array(int rat,int ku[10][10],int sum);
    void symmetric_call(int sm,int ku[10][10],int tm,int rat);
    void transitive_call(int mrtran[10][10],int rat,int f,int x);
    void relation_call(int summ,int sm,int f,int rat);
    void function_call(int q,int t,int summ,int r,int ku[10][10]);
    printf("\n enter m=:");
    scanf("%d",&m);
    printf("\n enter n=:");
    scanf("%d",&n);
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
        {
            printf("enter ku[%d][%d]",i,j);
            scanf("%d",&ku[i][j]);
        }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
            printf("%d",ku[i][j]);
        printf("\n");
    }
    matrix_array(rat,ku,sum);
    symmetric_call(s,ku,tm,rat);
    transitive_call(mrtran,rat,f,x);
    relation_call(sum,s,f,rat);
    function_call(q,t,summ,r,ku);
}

void matrix_array(int rat,int ku[10][10],int sum)
{
    int m,n,i,j;
    if(m==n)
    {
        for(i=0;i<m;i++)
            sum+=ku[i][i];
        if(sum==m)
            printf("\n\n **matrix is reflexive**");
        rat+=1;
    }
    if(sum==0)
        printf("\n\n **matrix is ireflexive**");
        if(sum!=m && sum!=0)
            printf("\n\n_the matrix is not reflexive and not ireflexive__");
}

void symmteric_call(int s,int ku[10][10],int tm,int rat)
{
    int s,tm,i,j;
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
            if(i!=j)
            {
                if(ku[i][j]!=ku[i][j])
                    s=1;
            }
    if(s!=1)
        printf("\n\n**matrex is symmetric**");
    else
        printf("\n\n*_*matrix is not symmetric*_*");
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
            if(i!=j)
            {
                if((ku[i][j]!=ku[j][i])||(ku[i][j]==0&&ku[j][i]==0))
                    tm+=1;
            }
    if(tm==(m*n)-m)
    {
        printf("\n\n**matrix is antisymmetric**");
        rat+=1;
    }
    else
        printf("\n\n*_*matrix is not antisymmetric*_*");
}

void transitive_call(int mrtran[10][10],int rat,int f,int x)
{
    int i,j;
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
        {
            for(x=0;x<n;x++)
                mrtran[i][j]=mrtran[i][j]+ku[i][x]*ku[x][j];
            if(mrtran[i][j]>1)
                mrtran[i][j]=1;
        }
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
            if(mrtran[i][j]>ku[i][j])
                f=1;
    if(f!=1)
        printf("\n\n**matrix is transitive**");
    rat+=1;
}
    else
        printf("\n\n*_*matrix is not transitive*_*");

void relation_call(int sum,int s,int f,int rat)
{
    if((sum==m)&&(s!=1)&&(f!=1))
        printf("\n\n**ku is an equivalence relation**\n");
    else
        printf("\n\n*_*ku is not an equivalence relation*_*");
    if(rat==3)
        printf("\n\n**partial ordering relation**");
    else
        printf("\n\n*_*not partial ordrring relation*_*");
}

void call_function(int q,int t,int summ,int r,int ku[10][10])
{
    q=0;
    for(i=0;i<m;i++)
    {
        summ=0;
        for(j=0;j<n;j++)
            summ+=ku[i][j];
        if(summ==1)
            q+=1;
    }
    if(q==m)
    {
        printf("\n\n***ku is function***");
        p=0;
        t=0;
        for(i=0;i<m;i++)
        {
            r=0;
            for(j=0;j<n;j++)
                r=r+ku[j][i];
            if(r>=1)
                p+=1;
            if(r==0||r==1)
                t+=1;
        }
        if(p==n)
            printf("\n ku is onto");
        else
            printf("\n ku is not onto");
        if(t==n)
            printf("\n ku is 1-1");
        else
            printf("\n mr is not 1-1");
    }
        else
            printf("\n\n*_is not a function_*");
}
if(m!=n)
{
    q=0;
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
            summ+=mr[i][j];
        if(summ==1)
            q+=1;
    }
    if(q==m)
    {
        printf("\n**function**");
        p=0;
        t=0;
        for(i=0;i<n;i++)
        {
            r=0;
            for(j=0;j<m;m++)
                r=r+mr[j][i];
            if(r>=1)
                p+=1;
            if(r==0||r==1)
                t+=1;
        }
    if(p==n)
        printf("\n is onto");
    else
        printf("\n is not onto");
    if(t==n)
        printf("\n is 1-1");
    }
else
    printf("\n>_<there is no function>_<");
}
Hopefully you see what is wrong now
put your { and } on their own lines, it make it easier for you and other to check the code

This post has been edited by FrozenSnake: 16 May 2010 - 02:56 PM

Was This Post Helpful? 0
  • +
  • -

#23 Darkness within  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 11
  • Joined: 16-May 10

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 03:09 PM

View PostFrozenSnake, on 16 May 2010 - 01:26 PM, said:

You should intend ALL code, and do not OVER intended it then you make it hard to read again, 1 tab per { is enough
int main()
{
    int someVariable;
    if(someVariable == 0)
    {
        if(true)
	    return 1; // Good
    }
    if(someVariable == 0)
    {
	if(true)
	                return 1; // bad
    }
}


I have been kind enough (one time thing!!!!) to intend your code (NOT FIXING IT).
#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j,x,sum=0,rat=0,s=0,f=0,q,summ=0,p,r,t,m,n,tm;
    int ku[10][10],mrtran[10][10];
    void matrix_array(int rat,int ku[10][10],int sum);
    void symmetric_call(int sm,int ku[10][10],int tm,int rat);
    void transitive_call(int mrtran[10][10],int rat,int f,int x);
    void relation_call(int summ,int sm,int f,int rat);
    void function_call(int q,int t,int summ,int r,int ku[10][10]);
    printf("\n enter m=:");
    scanf("%d",&m);
    printf("\n enter n=:");
    scanf("%d",&n);
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
        {
            printf("enter ku[%d][%d]",i,j);
            scanf("%d",&ku[i][j]);
        }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
            printf("%d",ku[i][j]);
        printf("\n");
    }
    matrix_array(rat,ku,sum);
    symmetric_call(s,ku,tm,rat);
    transitive_call(mrtran,rat,f,x);
    relation_call(sum,s,f,rat);
    function_call(q,t,summ,r,ku);
}

void matrix_array(int rat,int ku[10][10],int sum)
{
    int m,n,i,j;
    if(m==n)
    {
        for(i=0;i<m;i++)
            sum+=ku[i][i];
        if(sum==m)
            printf("\n\n **matrix is reflexive**");
        rat+=1;
    }
    if(sum==0)
        printf("\n\n **matrix is ireflexive**");
        if(sum!=m && sum!=0)
            printf("\n\n_the matrix is not reflexive and not ireflexive__");
}

void symmteric_call(int s,int ku[10][10],int tm,int rat)
{
    int s,tm,i,j;
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
            if(i!=j)
            {
                if(ku[i][j]!=ku[i][j])
                    s=1;
            }
    if(s!=1)
        printf("\n\n**matrex is symmetric**");
    else
        printf("\n\n*_*matrix is not symmetric*_*");
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
            if(i!=j)
            {
                if((ku[i][j]!=ku[j][i])||(ku[i][j]==0&&ku[j][i]==0))
                    tm+=1;
            }
    if(tm==(m*n)-m)
    {
        printf("\n\n**matrix is antisymmetric**");
        rat+=1;
    }
    else
        printf("\n\n*_*matrix is not antisymmetric*_*");
}

void transitive_call(int mrtran[10][10],int rat,int f,int x)
{
    int i,j;
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
        {
            for(x=0;x<n;x++)
                mrtran[i][j]=mrtran[i][j]+ku[i][x]*ku[x][j];
            if(mrtran[i][j]>1)
                mrtran[i][j]=1;
        }
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
            if(mrtran[i][j]>ku[i][j])
                f=1;
    if(f!=1)
        printf("\n\n**matrix is transitive**");
    rat+=1;
}
    else
        printf("\n\n*_*matrix is not transitive*_*");

void relation_call(int sum,int s,int f,int rat)
{
    if((sum==m)&&(s!=1)&&(f!=1))
        printf("\n\n**ku is an equivalence relation**\n");
    else
        printf("\n\n*_*ku is not an equivalence relation*_*");
    if(rat==3)
        printf("\n\n**partial ordering relation**");
    else
        printf("\n\n*_*not partial ordrring relation*_*");
}

void call_function(int q,int t,int summ,int r,int ku[10][10])
{
    q=0;
    for(i=0;i<m;i++)
    {
        summ=0;
        for(j=0;j<n;j++)
            summ+=ku[i][j];
        if(summ==1)
            q+=1;
    }
    if(q==m)
    {
        printf("\n\n***ku is function***");
        p=0;
        t=0;
        for(i=0;i<m;i++)
        {
            r=0;
            for(j=0;j<n;j++)
                r=r+ku[j][i];
            if(r>=1)
                p+=1;
            if(r==0||r==1)
                t+=1;
        }
        if(p==n)
            printf("\n ku is onto");
        else
            printf("\n ku is not onto");
        if(t==n)
            printf("\n ku is 1-1");
        else
            printf("\n mr is not 1-1");
    }
        else
            printf("\n\n*_is not a function_*");
}
if(m!=n)
{
    q=0;
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
            summ+=mr[i][j];
        if(summ==1)
            q+=1;
    }
    if(q==m)
    {
        printf("\n**function**");
        p=0;
        t=0;
        for(i=0;i<n;i++)
        {
            r=0;
            for(j=0;j<m;m++)
                r=r+mr[j][i];
            if(r>=1)
                p+=1;
            if(r==0||r==1)
                t+=1;
        }
    if(p==n)
        printf("\n is onto");
    else
        printf("\n is not onto");
    if(t==n)
        printf("\n is 1-1");
    }
else
    printf("\n>_<there is no function>_<");
}
Hopefully you see what is wrong now
put your { and } on their own lines, it make it easier for you and other to check the code


thanks about that
guys can you fix it now plz i really need it , its about a subject called descret the professor want us to creat a working program with certain condition to pass this subject if i didnt hand it tomorrow i will fail on it thats why i'm so need for it //
Was This Post Helpful? -3
  • +
  • -

#24 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 990
  • Joined: 30-July 08

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 03:36 PM

We don't fix things we help you fix it.
Check the source and see if you see how to fix it yourself.
It's your job to complete the homework NOT ours
If you have had your whole term on you and you cannot see what is wrong you do not deserve to pass it.

I can make my favorite quote for this occasion
Jack Klien said "If I do your home work, maybe you complete the course without learning to write a program like this. And later maybe you make the exam without learning to write a program like this. You might end up as a professional programmer without knowing how to write a program like this. One beautiful day maybe we work together on a project and you don’t know how to write a program like this. Then I must do you bodily harm."

This post has been edited by FrozenSnake: 16 May 2010 - 03:38 PM

Was This Post Helpful? 1
  • +
  • -

#25 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3089
  • View blog
  • Posts: 19,137
  • Joined: 14-September 07

Re: Declaration Terminated Incorrectly in my code

Posted 16 May 2010 - 03:38 PM

And on that note I'm closing this, we are getting nowhere fast.
Was This Post Helpful? 2
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2