473,387 Members | 1,374 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,387 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 2012
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.