Need help with function prototypes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dru
    New Member
    • Sep 2006
    • 29

    #16
    when ran like that i get this error in my compiler

    1>------ Build started: Project: Celsisu2a, Configuration: Debug Win32 ------
    1>Compiling...
    1>Celsius 2.c
    1>f:\documents\ visual studio\celsius 2\celsius 2\celsius 2.c(43) : error C2198: 'calculate' : too few arguments for call
    1>Build log was saved at "file://f:\Documents\Vi sual Studio\Celsisu2 a\Celsisu2a\Deb ug\BuildLog.htm "
    1>Celsisu2a - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Comment

    • ltgbau
      New Member
      • Sep 2006
      • 41

      #17
      post your code and i correct it for you :)

      Comment

      • dru
        New Member
        • Sep 2006
        • 29

        #18
        awesome

        Code:
        #include <stdio.h>
        
        double get_input(); /* prototype to get the input from the user */
        double calculate(); /* prototype to calculate the deggres into celsius */
        void output(double);    /* prototype to give the output */
        
        double get_input()
        {
           double fahrenheit;
           printf("Enter the degrees in Fahrenheit:");
           scanf_s(" %lf", &fahrenheit);  /** Get's the degrees in Fahrenheit temperature from the user using a scanf statement.**/
           return fahrenheit;
        }
        
        double calculate(double fahrenheit)    
        {          	
        	double celsius;           	
        	return (celsius = (get_input() - 32) * (5.0 / 9.0)); /*Calculates the degrees Celsius from the degrees Fahrenheit*/      
        } 
        
        void output(double celsius)
        {   
        	printf("Degrees in Celsius = %3.1f \n", calculate(celsius));/** Print you results to the output */
        }
        
        int main()
        
        {
          double fahrenheit = 0;/* temperature in degrees Fahrenheit */
          double celsius = 0;   /* temperature in degrees Celsius */
          get_input(); /* invokes get_input */
          calculate(); /* invokes calculate */
          output(celsius);    /* invokes output */
        
         return 0 ;
        
        }

        Comment

        • ltgbau
          New Member
          • Sep 2006
          • 41

          #19
          tested :))

          Code:
          #include <stdio.h>
          
          double get_input(); /* prototype to get the input from the user */
          double calculate(double fahrenheit); /* prototype to calculate the deggres into celsius */
          void output(double fahrenheit);    /* prototype to give the output */
          
          double get_input()
          {
          	double fahrenheit;
          	printf("Enter the degrees in Fahrenheit:");
          	scanf_s(" %lf", &fahrenheit);  /** Get's the degrees in Fahrenheit temperature from the user using a scanf statement.**/
          	return fahrenheit;
          }
          
          double calculate(double fahrenheit)    
          {          	
          	return ((fahrenheit - 32) * (5.0 / 9.0)); /*Calculates the degrees Celsius from the degrees Fahrenheit*/      
          } 
          
          void output(double fahrenheit)
          {   
          	printf("Degrees in Celsius = %3.1f \n", calculate(fahrenheit));/** Print you results to the output */
          }
          
          int main()
          
          {
            double fahrenheit = 0;/* temperature in degrees Fahrenheit */
            fahrenheit=get_input(); /* invokes get_input */
            output(fahrenheit);    /* invokes output */
          
           return 0 ;
          
          }

          Comment

          • dru
            New Member
            • Sep 2006
            • 29

            #20
            nice!!!!

            If you have time a haev a few questions

            Comment

            • ltgbau
              New Member
              • Sep 2006
              • 41

              #21
              ha ha
              it's 12:37 now in my location
              and i'm having lunch now.
              you can ask me later :)

              Comment

              • dru
                New Member
                • Sep 2006
                • 29

                #22
                ok thankyou
                141 am here cya

                Comment

                • vermarajeev
                  New Member
                  • Aug 2006
                  • 180

                  #23
                  Originally posted by dru
                  any1 got any ideas?

                  Code:
                  double calcuate(double fahrenheit)
                  Make this as

                  Code:
                  double calculate(double fahrenheit)
                  {

                  Comment

                  • ri153118
                    New Member
                    • May 2007
                    • 1

                    #24
                    how do you wire a c++ program that contains pre-defined and user-defined functions for a distance, radius, and area?

                    Comment

                    • Ganon11
                      Recognized Expert Specialist
                      • Oct 2006
                      • 3651

                      #25
                      Originally posted by ri153118
                      how do you wire a c++ program that contains pre-defined and user-defined functions for a distance, radius, and area?
                      Please ask your question in its own thread, with more explanation than this.

                      Comment

                      Working...