having error in c++ program as declaration syntax error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gaurav007
    New Member
    • Jan 2012
    • 2

    having error in c++ program as declaration syntax error

    #include<iostre am.h>
    int a(int,int);
    void main()
    {
    int n,m,x;
    cout<<"till what no. u want to run the program n=? \n ";
    cout<<"\n also enter by which u want to divide the no.s";
    cin>>n>>m;
    x=a(n,m);
    cout<<"factors of no.is"<<x;
    }
    int a(int x,int y)

    viod main()
    {
    for(int i=1,i<=x,i++)
    {
    if((i%y)==0)
    cout<< continue;
    else
    cout<<"no factors";
    }
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You have two main() functions and you have misspelled void in one of them.

    BTW: iostream.h has been obsolete for 14 years. You will need a newer compiler.

    Comment

    • Gaurav007
      New Member
      • Jan 2012
      • 2

      #3
      after spelling it right ....still having same problem.
      please can u edit or re code it 4 me....please please

      Comment

      • goldleaf
        New Member
        • Jan 2012
        • 1

        #4
        Ares will help you more on this.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          I can't code this for you. But you can re-post your code after you made your fixes.

          Comment

          • Nee B
            New Member
            • Dec 2011
            • 2

            #6
            You don't need a second void main() Or in your case a Viod main()
            You've already declared the function! No wonder there's a declaration error!

            Comment

            • shilpa george
              New Member
              • Oct 2011
              • 15

              #7
              hello gourav,


              int a(int x,int y)

              viod main()//------no need for this
              {
              for(int i=1,i<=x,i++)//-----------use semicolons instead of comma
              {
              if((i%y)==0)
              cout<< continue;/*---if this is a string plz put this inside quotes------*/
              else
              cout<<"no factors";
              }
              }

              if you are displaying the answers in the sub function then there is no need of giving a return type for the subfunction like
              int a(int x,int y)
              void a(int x,int y) is enough

              Comment

              Working...