Asked Oct 28, 2019

What are the components of a function and how do I use it in a program?


Expert Answer

Step 1

In programming language there are two types of function one is build in type and the other is user-defined.

The syntax of a function is:

returnType functionName (NumberOfArgument)





            return statement;


Step 2

Component of a function:

  1. Prototype declaration of a function
  2. Function definition
  3. Calling a function
  4. Number of arguments in a function
  5. Return statement of a function


  1.  Prototype declaration of a function means to declare a function before use it.

A function declaration tells the compiler the return type of a function, the name of the function and the number of the argument of a function.

For example:

Void functionAbc (int a, int b);

This function has a void return type then it not return any value.

functionAbc is the name of the function.

int a, int b are two integer type argument.

2. The function definition is to define the body of a function.

 For example:

Void functionAbc (int a, int b)


   //body of a function

    int  c = a+b;


Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in


Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add

Q: Simplify the following with Identities and K-Maps: xy~z + ~x~yz + yzPlease explain all steps

A: Karnaugh Map:Short form for Karnaugh map is “K-Map”.It is defined as a pictorial representation of g...


Q: Using the initial dependency diagram (attached), remove all partial dependencies, draw the new depen...

A: According to the given dependency diagram, there is no partial dependency but there are transitive d...


Q: Exercise 3.2.1: Here is a transition table for a DFA 0 1 92 qз *q3 q3 a) Give all the regular expres...

A: Since you have posted multiple questions and have not specified which question needs to be solved, w...


Q: How would I go about writing the code in the problem in the picture?

A: Program AlgorithmCreate a class Prime_Numbers and define the main() function.Initialize the required...


Q: Use the Design Recipe to write a function weighted_total(number_list,weights) that consumes a list o...

A: The given list of numbers is [1, 2, 3].The given weights are [0.1, 0.5, 0.4].weighted_total(number_l...


Q: write code in c++ to calculate f(0.006), wheref(x) = e−x − cos xln(x + 1)correctly to ten decimal pl...

A: Create a C++ program and include all required modules.Define a macro "e" with value 2.71828.Create a...


Q: A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 servi...

A: Program AlgorithmDeclare the required variable in the main().Get the input from the user for the num...


Q: Shipping is free for online orders totaling $25 or more at Orders less than $25 are...

A: Note: You didn't mention any language so i use Python#get the inputs from the userunit_cost = float(...


Q: E

A: E) The transition diagram for the given DFA is shown as: