Declaration syntax error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Abhishek Yadav

    Declaration syntax error

    Code:
    #include<stdio.h>
    #include<conio.h>
    int stat()
    main()
    {
    int i;
    clrscr();
    for(i=1;i<=4;i++)
    	{
    	stat();
    	}
    }
    void stat()
    	{
    	static int x;
    	x=x+1;
    	printf("x = %d",x);
    	}
    Last edited by Dormilich; Nov 26 '10, 10:08 AM. Reason: please use [CODE] [/CODE] tags when posting code
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You declare your stat() function to return an int but you code it to return void.

    Comment

    • ahsan farid

      #3
      declare your int stat(); not like int stat()
      second its int stat() not void stat()

      Comment

      • AHSANKATHIA
        New Member
        • Nov 2010
        • 7

        #4
        #include<stdio. h>
        #include<conio. h>
        int stat();
        main()
        {
        int i;
        clrscr();
        for(i=1;i<=4;i+ +)
        {
        stat();
        }
        }
        int stat()
        {
        static int x;
        x=x+1;
        printf("x = %d",x);
        }

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          Please use code tags, they make it much easier to refer to specific lines of your code.

          You define stat to return an int, but you allow execution to fall through to the closing brace. If the function has a return value then you must end the function with a return instruction that returns a value of the specified type.

          Comment

          Working...