Im having problems with prototypes anyone good with them?
24 3441
my code is -
#include <stdio.h>
-
-
double get_input(); /* prototype to get the input from the user */
-
double calculate(double); /* prototype to calculate the deggres into celsius */
-
void output(double, 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 calcuate(double fahrenheit)
-
{
-
double celsius;
-
return (celsius = (get_input(fahrenheit) - 32) * (5.0 / 9.0)); /*Calculates the degrees Celsius from the degrees Fahrenheit*/
-
-
}
-
-
void output(double fahrenheit, double celsius)
-
{
-
printf("Degrees in Fahrenheit = %3.1f \n", fahrenheit); /** Print you results to the output */
-
printf("Degrees in Celsius = %3.1f \n", calculate(celsius));/** Print you results to the output */
-
}
-
-
int main()
-
-
{
-
double fahrenheit;/* temperature in degrees Fahrenheit */
-
double celsius; /* temperature in degrees Celsius */
-
get_input( ); /* invokes get_input */
-
calculate(); /* invokes calculate */
-
output(fahrenheit, celsius); /* invokes output */
-
-
return (0);
-
-
}
-
-
please im begging someone to help me
- double calcuate(double fahrenheit) { double celsius; return (celsius = (get_input(fahrenheit) - 32) * (5.0 / 9.0)); /*Calculates the degrees Celsius from the degrees Fahrenheit*/ }
you use get_input in wrong way, it has no parameter. the right way is below: - double calcuate(double fahrenheit) { double celsius; return (celsius = (get_input() - 32) * (5.0 / 9.0)); /*Calculates the degrees Celsius from the degrees Fahrenheit*/ }
Banfa 9,065
Expert Mod 8TB
please im begging someone to help me
It has only been 20 minutes from your first post, you should wait 24 hours before a response like this just to give everyone the chance to wake-up and read your post. We are not all in the same time zone as you.
Your prototypes look fine, but you are not envoking the functions correctly -
get_input( ); /* invokes get_input */
-
calculate(); /* invokes calculate */
-
should be -
fahrenheit = get_input( ); /* invokes get_input */
-
celsius = calculate(fahrenheit); /* invokes calculate */
-
Error when ran:lgtbau's
f:\documents\visual studio\celsius 2\celsius 2\celsius 2.c(45) : error C2198: 'calculate' : too few arguments for call
i apologize for that its that i have been trying to figure this out for days and its due in less than 5 hours
but i reall apprecuiate the help
by the way this program is in C
Error when ran Banfa's
f:\documents\visual studio\celsius 2\celsius 2\celsius 2.c(45) : warning C4700: uninitialized local variable 'fahrenheit' used
1>f:\documents\visual studio\celsius 2\celsius 2\celsius 2.c(46) : warning C4700: uninitialized local variable 'celsius' used
1>Linking...
1>Celsius 2.obj : error LNK2019: unresolved external symbol _calculate referenced in function _main
1>F:\Documents\Visual Studio\Celsisu2a\Debug\Celsisu2a.exe : fatal error LNK1120: 1 unresolved externals
New Updated Code: -
#include <stdio.h>
-
-
double get_input(); /* prototype to get the input from the user */
-
double calculate(double); /* 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 calcuate(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", celsius);/** Print you results to the output */
-
}
-
-
int main()
-
-
{
-
double fahrenheit;/* temperature in degrees Fahrenheit */
-
double celsius; /* temperature in degrees Celsius */
-
get_input(); /* invokes get_input */
-
calculate(); /* invokes calculate */
-
output(celsius); /* invokes output */
-
-
return(0);
-
-
}
-
Errors coming up after compiled:
>------ Build started: Project: Celsisu2a, Configuration: Debug Win32 ------
>Compiling...
>Celsius 2.c
>f:\documents\visual studio\celsius 2\celsius 2\celsius 2.c(43) : error C2198: 'calculate' : too few arguments for call
>Build log was saved at "file://f:\Documents\Visual Studio\Celsisu2a\Celsisu2a\Debug\BuildLog.htm"
>Celsisu2a - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
double calcuate(double fahrenheit)
this function doesn't need the fahrenheit parameter
so it should be double calcuate()
try it.
onother error: the exact function name is calculate
Well I didn't try taht yet but I did try this and it works one problem though on my compiler for some reason it asks for degrees in farenheit 3 times before working any ideas here the code: -
/********************************************************************************
-
Name:Andrew Lichenstein Program:Celsius2.c
-
-
SS#:0287 Total Points:50
-
-
Due:09/13/2006
-
-
Description: This programs allows you to enter a temperature in Fahrenheit
-
and this program will convert it into Celsius by using prototypes.
-
*********************************************************************************/
-
-
#include <stdio.h>
-
-
double get_input(); /* prototype to get the input from the user */
-
double calculate(double); /* 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(fahrenheit); /* invokes calculate */
-
output(celsius); /* invokes output */
-
-
return 0 ;
-
-
}
-
I will try what you said while i wait
1st call in get_input
2nd call in calculate
3rd call in output
the problem is in the logic that you want the program to run, not in code - double calculate(double fahrenheit) { double celsius; return (celsius = (get_input() - 32) * (5.0 / 9.0)); /*Calculates the degrees Celsius from the degrees Fahrenheit*/ }
replace get_input() by fahrenheit
why does it make it ask input 3 times?
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\Visual Studio\Celsisu2a\Celsisu2a\Debug\BuildLog.htm"
1>Celsisu2a - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
post your code and i correct it for you :)
awesome -
#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 ;
-
-
}
-
tested :)) - #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 ;
-
-
}
nice!!!!
If you have time a haev a few questions
ha ha
it's 12:37 now in my location
and i'm having lunch now.
you can ask me later :)
ok thankyou
141 am here cya
any1 got any ideas?
- double calcuate(double fahrenheit)
Make this as - double calculate(double fahrenheit)
{
how do you wire a c++ program that contains pre-defined and user-defined functions for a distance, radius, and area?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: titan0111 |
last post by:
#include<iostream>
#include<iomanip>
#include<cstring>
#include<fstream>
using namespace std;
class snowfall
{
private:
int ft;
|
by: Robert |
last post by:
Hi,
I can use "with" like this:
function MyObject(message)
{
this.message = message;
}
function _MyObject_speak()
{
|
by: Norm Wong |
last post by:
If anyone is interested in using db2uext2 with Cygwin gcc compiler on
Windows, I've modified the IBM provided sample with the attached file.
There are two main modifications.
The mkdir command...
|
by: Grumble |
last post by:
Hello everyone,
I've come across some strange code. Here it is, stripped down:
int main(void)
{
int *foo;
int *bar();
foo = bar(0);
return 0;
|
by: TTroy |
last post by:
For function definitions (not declarations/prototypes), is it necessary
to put void in the emptry braces if the function is to receive no
parameters? Does this turn any error checking off or cause...
|
by: junky_fellow |
last post by:
Can a function have two different prototypes ? If not , then how can
main() have
two different prototypes ?
int main(void)
and
int main argc(int argc, char *argv)
I mean to say, if I declare...
|
by: wizwx |
last post by:
what does the following mean?
int func2();
According to C++, it surely means func2 is a function that takes no
argument and returns an integer. But what about in C? Does it have the
same...
|
by: lcdgoncalves |
last post by:
Hi everyone
Is there a real need to use keyword static with functions, if we
simply don't declare their prototypes in .h file?
Many textbooks avoid to discuss this matter and/or discuss only...
|
by: Steph Barklay |
last post by:
Hi, I'm currently taking a data structures course in C, and my teacher
said that function prototypes are not allowed in any of our code. He
also said that no professional programmers use function...
|
by: Ravishankar S |
last post by:
Dear C Experts,
While prepating a content for a C course,I made section on function
prototypes.
Could you kindly provide me your comments on its correctness. Thank you !
Q12: What is the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |