Function declarations and function definitions in cpp, C/C++ Programming

FUNCTIONS

It refers to a subprogram that is meant to do a certain task. It is basically used to execute a set of operations and return information to the main or calling function.

 

Basic Format:

return_data_type function_name(data_type par1, data_type par2,...)
{

Statement  1;

Statement  2;

}

Function Declarations and Function Definitions

Every function in program must have a function declaration and a function definition. Function declaration refers to the functions name, return data type and parameters (function prototype) while Function definition refers to the implementation of a particular function. Function declaration and function definition appear together to form a function

 

Static type checking

It refers to the checking of the data types used in all functions are appropriate to the actual function

requirements. This ensures that any function cannot be called with wrong number of parameters or

inappropriate argument types  i.e. C++ does not allow any function to be used before it has been declared and the reason is that the compiler can perform static type checking.

 

Function prototypes

This is a function declaration statement that informs the compiler of the type of data returned by the
functions, the number of parameters the function expects and order in which they are expected.
Format:

return_type function_name  (list of parameters); 

 

Posted Date: 8/21/2012 11:48:25 AM | Location : United States







Related Discussions:- Function declarations and function definitions in cpp, Assignment Help, Ask Question on Function declarations and function definitions in cpp, Get Answer, Expert's Help, Function declarations and function definitions in cpp Discussions

Write discussion on Function declarations and function definitions in cpp
Your posts are moderated
Related Questions
C Program for ADD,SUB,MUL,DIV,REM void main() {   int a,b,c,ch=0;           clrscr();           while(ch           { printf(" \n\n 1:- For To Add\n 2:- For

i am a engineering student and am working on a project in audio processing and so i have designed a FIR filter in Matlab . how can i get my Matlab program converted to C program?

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

how to do 2, 4, 8 associativity

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Study the given class specification and answer the questions that follow: class Person { private:   string name;   int yrBorn;   int yrDied;   public:   Per

Specifying a Class: As discussed a class is defined to develop an algorithm and bind it together in a core shell. A class is an abstract data type (ADT).  The binding of dat

Define the Stream Oriented Data Files? There are two dissimilar types of data files called stream-oriented (or standard) data files and system-oriented (or low-level) data file

1. write a program named InputMethodDemo2 that eliminates the repetitive code in the InputMethod() in the InputMethodDemo program. Rewrite the program so the InputMethod()contains