473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting error name Function should have prototype

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
int i=1,j=2;
float k,l=1.5;

printf("%d %d\n",i,j);
printf("%d",i,j);
k=square(l);
printf("%f\n",k);


}
float square(float m)
{
float z;
z=m*m;
return(z);
}
Aug 25 '14 #1
3 2014
weaknessforcats
9,208 Expert Mod 8TB
You have this function:
Expand|Select|Wrap|Line Numbers
  1. float square(float m)
  2.  {
  3.  float z;
  4.  z=m*m;
  5.  return(z);
  6.  } 
You call this function in main(). Unfortunately, the compiler hasn't seen the function yet so it thinks there is an error.

In this case, you copy the first line of the function and follow it with a semi-colon:

Expand|Select|Wrap|Line Numbers
  1. float square(float m);
  2.  
Put this line of code above the main() function. When the compiler sees this prototype, it will allow the call even though it hasn't seen the code yet. The code may be in another file.

This is the function prototype that s being requested.
Aug 25 '14 #2
Read this about the need for prototypes. Read mark_poc's response:
https://answers.yahoo.com/question/i...4193724AAbb3Lo
Aug 26 '14 #3
donbock
2,426 Expert 2GB
You are familiar with the need to declare variables before using them. Similarly, the compiler expects you to declare functions before you use them. There are three ways to satisfy this need:
  1. With a function prototype (as described above by @weaknessforcats). This identifies the return type of the function, the number of parameters, and the types of each parameter.
  2. Define (implement) the function before you use it. The function definition acts as a declaration. This leads to an "inside-out" layout of the source file where the lowest-level functions appear first and you have to start at the bottom of the file to see the big picture.
  3. Use old-style function declarations (that identify only the return type of the function and say nothing about the parameters). The old-style declarations have been deprecated since function prototypes were introduced in the late 1980's. Don't do this.
Aug 26 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: IMS.Rushikesh | last post by:
Hi Friends, My work is stuck up because of this unresolvable and unbelievable Error. I'm trying to Serialize my Class object using XmlSerialization. And at below line, I m getting "error File...
4
by: ItsMe | last post by:
Hi Guyz, I'm unable to understand this (AddressOf) error??? In VB6 I have two functions: ---------------------------- Public Function ImageFirstImageCallback(ByVal hWnd As Integer, ByVal...
1
by: rdemyan via AccessMonster.com | last post by:
I'm trying to code restoring my app from a backup file. This is all being done from a logon form. Here's the relevant code: Code:...
32
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is...
1
by: bagya | last post by:
please help me out the following is the small code i have <html> <head> <script type="text/javascript"> function validate() { if (document.abc.region.value==0)
5
by: Daz | last post by:
Hi everyone. My query is very straight forward (I think). What's the difference between someFunc.blah = function(){ ; } and
8
by: ipy2006 | last post by:
In my HTML I have, <input type="button" class="cartonsumkey" value="Sum Cartons" onclick="sumup(this);" /> In an external file that is called in Head area, I have, function sumup( o ) { ...
21
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
3
by: swapnali143 | last post by:
Can anybody tell me how to fix an error "GETLINE should have a prototype when i run following code under TC environment #include<iostream.h> #include<conio.h> #include<fstream.h>...
1
by: RajniRamShinde | last post by:
My error is function 'capture' should have prototype in c++ ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.