please help me! what is wrong ????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • memol
    New Member
    • Nov 2007
    • 1

    please help me! what is wrong ????

    /*in this part i'm giving sum data but i have error...please talk with me about my program */
    #include<iostre am.h>
    #include<string .h>
    #include<conio. h>
    void point(int*,int* ,int*);
    void goal(int*,int*) ;
    int name(char[40][40],int,int);
    int Time(int[4][10],int,int);
    int time(int[4][10],int,int);
    void main()
    {
    int G1,g1,G2,g2,G3, g3,G4,g4,G5,g5;
    int G1sum=0,G2sum=0 ,G3sum=0,G4sum= 0,G5sum=0;
    int g1sum=0,g2sum=0 ,g3sum=0,g4sum= 0,g5sum=0;
    int p1,p2,p3,p4,p5, P1=0,P2=0,P3=0, P4=0,P5=0;
    int T1[4][10],T2[4][10],T3[4][10],T4[4][10],T5[4][10];
    int t1[4][10],t2[4][10],t3[4][10],t4[4][10],t5[4][10];
    int i=0,j=0,k=0,z=0 ,num=1;
    char team[5][20],steam[20];
    char n1[40][40],n2[40][40],n3[40][40],n4[40][40],n5[40][40];
    for(i=0;i<5;i++ ){
    cout<<"Enter name of "<<(i+1)<<" th team:";
    cin>>team[i];
    }
    cout<<"\nNow enter details for each one...";
    while(num<6){
    cout<<"\nPlease enter name of one of them:" ;
    cin>>steam;
    if(strcmp(steam ,team[0])==0){
    for(i=1;i<5;i++ ){
    cout<<"\nEnter reports for "<<team[0]<<" VS "<<team[i]<<" please...";
    goal(&G1,&g1);
    G1sum+=G1;
    g1sum+=g1;
    point(&G1,&g1,& p1);
    P1+=p1;
    j=name(n1,G1sum ,j);
    k=Time(T1,G1,k) ;
    z=time(t1,g1,z) ;
    }
    j=k=z=0;
    continue;
    }//end of first if
    else if(strcmp(steam ,team[1])==0){
    for(i=0;i<5;i++ ){
    if(i==1)
    i++;
    cout<<"\nEnter reports for "<<team[1]<<" VS "<<team[i]<<" please...";
    goal(&G2,&g2);
    G2sum+=G2;
    g2sum+=g2;
    point(&G2,&g2,& p2);
    P2+=p2;
    j=name(n2,G2sum ,j);
    k=Time(T2,G2,k) ;
    z=time(t2,g2,z) ;
    }
    j=k=z=0;
    continue;
    }//end of second if
    else if(strcmp(steam ,team[2])==0){
    for(i=0;i<5;i++ ){
    if(i==2)
    i++;
    cout<<"\nEnter reports for "<<team[2]<<" VS "<<team[i]<<" please...";
    goal(&G3,&g3);
    G3sum+=G3;
    g3sum+=g3;
    point(&G3,&g3,& p3);
    P3+=p3;
    j=name(n3,G3sum ,j);
    k=Time(T3,G3,k) ;
    z=time(t3,g3,z) ;
    }
    j=k=z=0;
    continue;
    }//end of third if
    else if(strcmp(steam ,team[3])==0){
    for(i=0;i<5;i++ ){
    if(i==3)
    i++;
    cout<<"\nEnter reports for "<<team[3]<<" VS "<<team[i]<<" please...";
    goal(&G4,&g4);
    G4sum+=G4;
    g4sum+=g4;
    point(&G4,&g4,& p4);
    P4+=p4;
    j=name(n4,G4sum ,j);
    k=Time(T4,G4,k) ;
    z=time(t4,g4,z) ;
    }
    j=k=z=0;
    continue;
    }//end of fourth if
    else if(strcmp(steam ,team[4])==0){
    for(i=0;i<4;i++ ){
    cout<<"\nEnter reports for "<<team[4]<<" VS "<<team[i]<<" please...";
    goal(&G5,&g5);
    G5sum+=G5;
    g5sum+=g5;
    point(&G5,&g5,& p5);
    P5+=p5;
    j=name(n5,G5sum ,j);
    k=Time(T5,G5,k) ;
    z=time(t5,g5,z) ;
    }
    j=k=z=0;
    continue;
    }
    else
    cout<<"\nYou entered unknown team!Try again...";
    num++;
    }
    }


    void goal(int*p1,int *p2)
    {
    cout<<"\ngolhay e zade:";
    cin>>*p1;
    cout<<"golhaye khorde:";
    cin>>*p2;
    }


    void point(int*p1,in t*p2,int*p3)
    {
    if(*p1>*p2)
    *p3=3;
    else
    *p3=1;
    }


    int name(char n[40][40],int sum,int j)
    {
    for(j;j<sum;j++ ){
    cout<<"\nwho goals?(After a name press ENTER):";
    cin.get();
    cin.get(n[j],40);
    }
    return j;
    }


    int Time(int T[4][10],int G,int k)
    {
    int j;
    for(j=0;j<G;j++ ){
    cout<<"\nEnter time of "<<(j+1)<<" th goal(by minute) which the team shooted:";
    cin>>T[k][j];
    }
    return k;
    }


    int time(int t[4][10],int g,int z)
    {
    int j;
    for(j=0;j<g;j++ ){
    cout<<"\nEnter time of "<<(j+1)<<" th goal(by minute) which the team received:";
    cin>>t[z][j];
    }
    return z;
    }
  • xoinki
    New Member
    • Apr 2007
    • 110

    #2
    hi
    y du u want to assign some data before #include?
    just do it afterwards and c
    Thnx
    Xoinki

    Comment

    • karthickbabu
      New Member
      • Sep 2007
      • 33

      #3
      No error in your program. Its runs safely. What compiler u r using. I copy your code and run in VC++ compiler.

      What error u get





      regards,
      karthickbabu

      Originally posted by memol
      /*in this part i'm giving sum data but i have error...please talk with me about my program */
      #include<iostre am.h>
      #include<string .h>
      #include<conio. h>
      void point(int*,int* ,int*);
      void goal(int*,int*) ;
      int name(char[40][40],int,int);
      int Time(int[4][10],int,int);
      int time(int[4][10],int,int);
      void main()
      {
      int G1,g1,G2,g2,G3, g3,G4,g4,G5,g5;
      int G1sum=0,G2sum=0 ,G3sum=0,G4sum= 0,G5sum=0;
      int g1sum=0,g2sum=0 ,g3sum=0,g4sum= 0,g5sum=0;
      int p1,p2,p3,p4,p5, P1=0,P2=0,P3=0, P4=0,P5=0;
      int T1[4][10],T2[4][10],T3[4][10],T4[4][10],T5[4][10];
      int t1[4][10],t2[4][10],t3[4][10],t4[4][10],t5[4][10];
      int i=0,j=0,k=0,z=0 ,num=1;
      char team[5][20],steam[20];
      char n1[40][40],n2[40][40],n3[40][40],n4[40][40],n5[40][40];
      for(i=0;i<5;i++ ){
      cout<<"Enter name of "<<(i+1)<<" th team:";
      cin>>team[i];
      }
      cout<<"\nNow enter details for each one...";
      while(num<6){
      cout<<"\nPlease enter name of one of them:" ;
      cin>>steam;
      if(strcmp(steam ,team[0])==0){
      for(i=1;i<5;i++ ){
      cout<<"\nEnter reports for "<<team[0]<<" VS "<<team[i]<<" please...";
      goal(&G1,&g1);
      G1sum+=G1;
      g1sum+=g1;
      point(&G1,&g1,& p1);
      P1+=p1;
      j=name(n1,G1sum ,j);
      k=Time(T1,G1,k) ;
      z=time(t1,g1,z) ;
      }
      j=k=z=0;
      continue;
      }//end of first if
      else if(strcmp(steam ,team[1])==0){
      for(i=0;i<5;i++ ){
      if(i==1)
      i++;
      cout<<"\nEnter reports for "<<team[1]<<" VS "<<team[i]<<" please...";
      goal(&G2,&g2);
      G2sum+=G2;
      g2sum+=g2;
      point(&G2,&g2,& p2);
      P2+=p2;
      j=name(n2,G2sum ,j);
      k=Time(T2,G2,k) ;
      z=time(t2,g2,z) ;
      }
      j=k=z=0;
      continue;
      }//end of second if
      else if(strcmp(steam ,team[2])==0){
      for(i=0;i<5;i++ ){
      if(i==2)
      i++;
      cout<<"\nEnter reports for "<<team[2]<<" VS "<<team[i]<<" please...";
      goal(&G3,&g3);
      G3sum+=G3;
      g3sum+=g3;
      point(&G3,&g3,& p3);
      P3+=p3;
      j=name(n3,G3sum ,j);
      k=Time(T3,G3,k) ;
      z=time(t3,g3,z) ;
      }
      j=k=z=0;
      continue;
      }//end of third if
      else if(strcmp(steam ,team[3])==0){
      for(i=0;i<5;i++ ){
      if(i==3)
      i++;
      cout<<"\nEnter reports for "<<team[3]<<" VS "<<team[i]<<" please...";
      goal(&G4,&g4);
      G4sum+=G4;
      g4sum+=g4;
      point(&G4,&g4,& p4);
      P4+=p4;
      j=name(n4,G4sum ,j);
      k=Time(T4,G4,k) ;
      z=time(t4,g4,z) ;
      }
      j=k=z=0;
      continue;
      }//end of fourth if
      else if(strcmp(steam ,team[4])==0){
      for(i=0;i<4;i++ ){
      cout<<"\nEnter reports for "<<team[4]<<" VS "<<team[i]<<" please...";
      goal(&G5,&g5);
      G5sum+=G5;
      g5sum+=g5;
      point(&G5,&g5,& p5);
      P5+=p5;
      j=name(n5,G5sum ,j);
      k=Time(T5,G5,k) ;
      z=time(t5,g5,z) ;
      }
      j=k=z=0;
      continue;
      }
      else
      cout<<"\nYou entered unknown team!Try again...";
      num++;
      }
      }


      void goal(int*p1,int *p2)
      {
      cout<<"\ngolhay e zade:";
      cin>>*p1;
      cout<<"golhaye khorde:";
      cin>>*p2;
      }


      void point(int*p1,in t*p2,int*p3)
      {
      if(*p1>*p2)
      *p3=3;
      else
      *p3=1;
      }


      int name(char n[40][40],int sum,int j)
      {
      for(j;j<sum;j++ ){
      cout<<"\nwho goals?(After a name press ENTER):";
      cin.get();
      cin.get(n[j],40);
      }
      return j;
      }


      int Time(int T[4][10],int G,int k)
      {
      int j;
      for(j=0;j<G;j++ ){
      cout<<"\nEnter time of "<<(j+1)<<" th goal(by minute) which the team shooted:";
      cin>>T[k][j];
      }
      return k;
      }


      int time(int t[4][10],int g,int z)
      {
      int j;
      for(j=0;j<g;j++ ){
      cout<<"\nEnter time of "<<(j+1)<<" th goal(by minute) which the team received:";
      cin>>t[z][j];
      }
      return z;
      }

      Comment

      • Swapnadeep
        New Member
        • Nov 2007
        • 1

        #4
        Originally posted by memol
        /*in this part i'm giving sum data but i have error...please talk with me about my program */
        #include<iostre am.h>
        #include<string .h>
        #include<conio. h>
        void point(int*,int* ,int*);
        void goal(int*,int*) ;
        int name(char[40][40],int,int);
        int Time(int[4][10],int,int);
        int time(int[4][10],int,int);
        void main()
        {
        int G1,g1,G2,g2,G3, g3,G4,g4,G5,g5;
        int G1sum=0,G2sum=0 ,G3sum=0,G4sum= 0,G5sum=0;
        int g1sum=0,g2sum=0 ,g3sum=0,g4sum= 0,g5sum=0;
        int p1,p2,p3,p4,p5, P1=0,P2=0,P3=0, P4=0,P5=0;
        int T1[4][10],T2[4][10],T3[4][10],T4[4][10],T5[4][10];
        int t1[4][10],t2[4][10],t3[4][10],t4[4][10],t5[4][10];
        int i=0,j=0,k=0,z=0 ,num=1;
        char team[5][20],steam[20];
        char n1[40][40],n2[40][40],n3[40][40],n4[40][40],n5[40][40];
        for(i=0;i<5;i++ ){
        cout<<"Enter name of "<<(i+1)<<" th team:";
        cin>>team[i];
        }
        cout<<"\nNow enter details for each one...";
        while(num<6){
        cout<<"\nPlease enter name of one of them:" ;
        cin>>steam;
        if(strcmp(steam ,team[0])==0){
        for(i=1;i<5;i++ ){
        cout<<"\nEnter reports for "<<team[0]<<" VS "<<team[i]<<" please...";
        goal(&G1,&g1);
        G1sum+=G1;
        g1sum+=g1;
        point(&G1,&g1,& p1);
        P1+=p1;
        j=name(n1,G1sum ,j);
        k=Time(T1,G1,k) ;
        z=time(t1,g1,z) ;
        }
        j=k=z=0;
        continue;
        }//end of first if
        else if(strcmp(steam ,team[1])==0){
        for(i=0;i<5;i++ ){
        if(i==1)
        i++;
        cout<<"\nEnter reports for "<<team[1]<<" VS "<<team[i]<<" please...";
        goal(&G2,&g2);
        G2sum+=G2;
        g2sum+=g2;
        point(&G2,&g2,& p2);
        P2+=p2;
        j=name(n2,G2sum ,j);
        k=Time(T2,G2,k) ;
        z=time(t2,g2,z) ;
        }
        j=k=z=0;
        continue;
        }//end of second if
        else if(strcmp(steam ,team[2])==0){
        for(i=0;i<5;i++ ){
        if(i==2)
        i++;
        cout<<"\nEnter reports for "<<team[2]<<" VS "<<team[i]<<" please...";
        goal(&G3,&g3);
        G3sum+=G3;
        g3sum+=g3;
        point(&G3,&g3,& p3);
        P3+=p3;
        j=name(n3,G3sum ,j);
        k=Time(T3,G3,k) ;
        z=time(t3,g3,z) ;
        }
        j=k=z=0;
        continue;
        }//end of third if
        else if(strcmp(steam ,team[3])==0){
        for(i=0;i<5;i++ ){
        if(i==3)
        i++;
        cout<<"\nEnter reports for "<<team[3]<<" VS "<<team[i]<<" please...";
        goal(&G4,&g4);
        G4sum+=G4;
        g4sum+=g4;
        point(&G4,&g4,& p4);
        P4+=p4;
        j=name(n4,G4sum ,j);
        k=Time(T4,G4,k) ;
        z=time(t4,g4,z) ;
        }
        j=k=z=0;
        continue;
        }//end of fourth if
        else if(strcmp(steam ,team[4])==0){
        for(i=0;i<4;i++ ){
        cout<<"\nEnter reports for "<<team[4]<<" VS "<<team[i]<<" please...";
        goal(&G5,&g5);
        G5sum+=G5;
        g5sum+=g5;
        point(&G5,&g5,& p5);
        P5+=p5;
        j=name(n5,G5sum ,j);
        k=Time(T5,G5,k) ;
        z=time(t5,g5,z) ;
        }
        j=k=z=0;
        continue;
        }
        else
        cout<<"\nYou entered unknown team!Try again...";
        num++;
        }
        }


        void goal(int*p1,int *p2)
        {
        cout<<"\ngolhay e zade:";
        cin>>*p1;
        cout<<"golhaye khorde:";
        cin>>*p2;
        }


        void point(int*p1,in t*p2,int*p3)
        {
        if(*p1>*p2)
        *p3=3;
        else
        *p3=1;
        }


        int name(char n[40][40],int sum,int j)
        {
        for(j;j<sum;j++ ){
        cout<<"\nwho goals?(After a name press ENTER):";
        cin.get();
        cin.get(n[j],40);
        }
        return j;
        }


        int Time(int T[4][10],int G,int k)
        {
        int j;
        for(j=0;j<G;j++ ){
        cout<<"\nEnter time of "<<(j+1)<<" th goal(by minute) which the team shooted:";
        cin>>T[k][j];
        }
        return k;
        }


        int time(int t[4][10],int g,int z)
        {
        int j;
        for(j=0;j<g;j++ ){
        cout<<"\nEnter time of "<<(j+1)<<" th goal(by minute) which the team received:";
        cin>>t[z][j];
        }
        return z;
        }
        Hi Memol,
        Gone through your code. The code seems working fine and does not has any issues. But can you just amend a few things so that the things become easier for you and everyone reading your code.
        1.> Why have you taken so many global variables in the program? Although you have used very little.
        2.> Can you please rename the variables and use the give them the appropriate names so that the variables look more programatic and traced down well?
        3.> Can you please trace the program by using comments at appropriate places?
        Hope this all improves your programming skills and you write excellent programs.... :-) :-)
        Kudos and Cheers,

        Comment

        Working...