Question

What are functions? List and define 3 types of function. Why is this abstraction of any...

What are functions? List and define 3 types of function. Why is this abstraction of any use?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

FUNCTION:---

A function in C is a block of code that performs a specific task. functions are basic building blocks in a program. All C programs are written using functions to improve re-usability, understandability and to keep track on them.This can be calculating the area of a triangle or shuffling a deck of cards.

A large C program is divided into basic building blocks called C function. C function contains set of instructions enclosed by “{ }” which performs specific operation in a C program.

USES OF C FUNCTIONS:

  • The core concept of C functions are, re-usability, dividing a big task into small pieces to achieve the functionality and to improve understandability of very large C programs.
  • C functions are used to avoid rewriting same logic/code again and again in a program.
  • There is no limit in calling C functions to make use of same functionality wherever required.

There are Two Types of Functions

• Built in Functions

The Functions those are provided by C Language are refers to the Built in Functions For example. cin and cout, getch , Clrscr are the Examples of Built in Functions. So that all the functions those are provided by the C++ Language are Pre defined and Stored in the Form of header Files so that a user doesn’t need to Know how this Function has developed and a user just use that Function.

• User Defined functions

the Functions those are developed by the user for their Programs are known as User Defined Programs.

types of function calling

1.Call by value

This method copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.

Different Memory is allocated for both actual and formal parameters. Because, value of actual parameter is copied to formal parameter.

Call by reference

This method copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call.

The value of the actual parameter can be modified by formal parameter.Same memory is used for both actual and formal parameters since only address is used by both parameters.

ABSTRACTION:-

In the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency.Abstraction is related to both encapsulation and data hiding.Abstraction is one of the key elements of good software design. It helps encapsulate behavior. It helps decouple software elements.Abstraction means displaying only essential information and hiding the details.When developing with higher level of abstraction, you communicate the behavior and less the implementation.

Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.

Advantages of Data Abstraction:

  • Helps the user to avoid writing the low level code
  • Avoids code duplication and increases reusability.
  • Can change internal implementation of class independently without affecting the user.
  • Helps to increase security of an application or program as only important details are provided to the user.
Add a comment
Know the answer?
Add Answer to:
What are functions? List and define 3 types of function. Why is this abstraction of any...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT