Compiling issues in Windows Vista with Turbo C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AdrianH
    Recognized Expert Top Contributor
    • Feb 2007
    • 1251

    #16
    Originally posted by goutham1
    inspite of including # include <stdio.h>iam getting an error statement function should return a value.

    please see this.
    thanks for ur help.
    What function?

    I would suggest if you get an error message, post it. It will make diagnosing your problems a lot easier.


    Adrian

    Comment

    • goutham1
      New Member
      • May 2007
      • 13

      #17
      Originally posted by AdrianH
      What function?

      I would suggest if you get an error message, post it. It will make diagnosing your problems a lot easier.


      Adrian
      my programme is about calculating percentages .of total 5 subjects in if statement.at the end of programme i wrote getch();return( 0);.at the closing of statements there is a warning like function should return a value. what should i include so that my programme will be executed.

      please post me reply for this thanks.

      Comment

      • AdrianH
        Recognized Expert Top Contributor
        • Feb 2007
        • 1251

        #18
        Originally posted by goutham1
        my programme is about calculating percentages .of total 5 subjects in if statement.at the end of programme i wrote getch();return( 0);.at the closing of statements there is a warning like function should return a value. what should i include so that my programme will be executed.

        please post me reply for this thanks.
        PM me the code.


        Adrian

        Comment

        • goutham1
          New Member
          • May 2007
          • 13

          #19
          Originally posted by AdrianH
          PM me the code.


          Adrian
          my programme is this
          code removed as per posting guidelines

          after compiling my programme there is a waring in the last statement

          that "function should return a value."

          thanks

          Comment

          • AdrianH
            Recognized Expert Top Contributor
            • Feb 2007
            • 1251

            #20
            Originally posted by goutham1
            my programme is this
            code removed as per posting guidelines

            after compiling my programme there is a waring in the last statement

            that "function should return a value."

            thanks
            PM me means "Private Message" me.

            I've gotten the code.


            Adrian

            Comment

            • AdrianH
              Recognized Expert Top Contributor
              • Feb 2007
              • 1251

              #21
              The code you posted is pretty sloppy. I’m surprised that a compiler would accept it. Things wrong:
              1. main() returns an int. You should specify this even if the C standard says you don’t need to.
              2. Your indenting was unreadable.
              3. You mistyped an end parenthesis with a 0. This could not be the code you were using.
              4. if bodies and else bodies should have braces ({}) around them, otherwise you are just wishing for a problem to happen.
              5. per is not initialised before use
              6. getch() is not part of stdio.h, use scanf(“%*[^\n]”) to wait for a enter key to be pressed instead.
              7. Not all execution paths return a value
              8. You didn’t add anything (that was your original question, right?).

              So what do you want to do from here?


              Adrian

              Comment

              • goutham1
                New Member
                • May 2007
                • 13

                #22
                Originally posted by AdrianH
                The code you posted is pretty sloppy. I’m surprised that a compiler would accept it. Things wrong:
                1. main() returns an int. You should specify this even if the C standard says you don’t need to.
                2. Your indenting was unreadable.
                3. You mistyped an end parenthesis with a 0. This could not be the code you were using.
                4. if bodies and else bodies should have braces ({}) around them, otherwise you are just wishing for a problem to happen.
                5. per is not initialised before use
                6. getch() is not part of stdio.h, use scanf(“%*[^\n]”) to wait for a enter key to be pressed instead.
                7. Not all execution paths return a value
                8. You didn’t add anything (that was your original question, right?).

                So what do you want to do from here?


                Adrian
                so what u told me i have done inspite of this iam getting an error msg like

                function should return a value.


                iam using cpp compiler so i hve changed my file name to .c and iam doing this.

                programme but iam getting this problem.


                can u please post the programme for me. the programme is about calculating per in 5 sub
                and using if statement with the respective division calculating per and displayin the statement.

                thans for ur reply

                Comment

                • roraka
                  New Member
                  • Sep 2007
                  • 1

                  #23
                  Originally posted by goutham1
                  so what u told me i have done inspite of this iam getting an error msg like

                  function should return a value.


                  iam using cpp compiler so i hve changed my file name to .c and iam doing this.

                  programme but iam getting this problem.


                  can u please post the programme for me. the programme is about calculating per in 5 sub
                  and using if statement with the respective division calculating per and displayin the statement.

                  thans for ur reply
                  hey dude the first thingy u got to do is use
                  printf ("enter the value of a \n");
                  and not
                  printf ("enter the value of a \n",a);

                  next give main declaration as
                  void main(void)

                  and then remove ur return statement.

                  the correct code is
                  void main ( )
                  {
                  int a, b, c;
                  printf("enter a number a \n");
                  scanf("%d",&a);
                  printf("enter a number b \n");
                  scanf("%d",&b);
                  printf("enter a number c \n");
                  scanf("%d",&c);
                  }

                  Comment

                  Working...