void main()

int n;
int f,c;
cout<<"1:enter the faranheit value to convert:";
cout<<"2:enter the celscious value to convert:";
case 1:
case 2:
     cout<<"try 1 or 2";


float ctof(float d)
  cout<<"faranheit value is:"<<d;
  return d;
float ftoc(float f)
cout<<"celcious value is:"<<f;
return f;

okay this must looks stupid but I am new to the prograaming...why I am getting error "function "ftoc and ctof" shold have prototype"

Recommended Answers

All 3 Replies

You must declare a function before you call it, at lines 16/19 you respectively call ftoc/ctoc but this is the first time the compiler has seen those functions (it reads the file line by line).

All you need to do is arround line 3 add the code lines

static float ctof(float d);
static float ctof(float d);

This tells the compiler about those functions, their parameters what they return and allows the calls at line 16/19. This is part of the stricter type checking that C++ does.

You have two options here:
1. Move the code for the two functions above main, so they are defined before main
2. Create two function prototypes for the functions before main

float ctof(float d);
float ftoc(float f);

Also you appear to be missing an opening brace '{' after main() and according to the C++ standard, the signature of main should be int main() not void main()

Another thing:
Take note that the entire user input section of your code is wrong and will not do what you are hoping to do! For starters n is never initialised, or set to anything. So your switch statement will most likely only ever use the default case and the two values entered for f and c will never be used by the program.

For the user input section of your code, I'm guessing what you need to do is ask the user for a value, then ask whether they want to convert from celsius to farenheit, or farenheit to celcius. Or perhaps you need to ask them to enter the type of conversion they want to do and then ask for the value. But what you have at the moment does neither of those things! You need to go back to the drawing board and rethink your solution to the problem a little!

Beaten to the punch by Banfa! :)

really this is great and u are right, I need to think on my solution before writing the programs...
I just solved it...I love u guys:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.