Def : Function is a sub part of program used to perform specific task and is executed individually.
Advantages :
Reuseability i.e. a function may be used by many other programs.
The length of the source program can be reduced.
It is easy to locate and isolate a faculty function.
It facilitates top-down modular programming.
Top Down Design and Structure Charts :
“Top - Down Design” is a problem solving method in which a complex problem is solved by breaking up into sub problems.
It proceeds from the original problem at the top level to the sub problems at each lower level.
“Structure Chart” is a documentation tool that shows the relationships among the sub problems of a problem.
The splitting of a problem into its related sub problems is analogous to the process of refining on algorithm.
E.g. Performing arithmetic operations on 2 numbers
Find Sum
Find Difference
Find Product
Find Quotient
Refined Algorithm for Step 1 :
1.1 take 2 numbers a, b
1.2 sum, c = a + b
1.3 print sum
Structure Chart :
Please Login For Further Details...
Q1 : What is a Function in C Language?
A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions.
Q2 : What are the advantages of Functions in C program?
1. Reusability i.e. a function may be used by many other programs.
2. The length of the source program can be reduced.
3. It is easy to locate and isolate a faculty function.
4. It facilitates top-down modular programming.
Q3 : What is the main function?
The Main Function. In C, the "main" function is treated the same as every function, it has a return type (and in some cases accepts inputs via parameters). The only difference is that the main function is "called" by the operating system when the user runs the program.
Q4 : What are predefined functions in C?
Library functions in C language are inbuilt functions which are grouped together and placed in a common place called library. All C standard library functions are declared in many header files which are saved as file_name.h. Actually, function declaration, definition for macros are given in all header files.
Q5 : What are the input and output functions in C?
The C language provides a set of library functions to perform input and output (I/O) operations. Those functions can read or write any type of data to files. In C, a file can refer to a disk file, a terminal, a printer, etc.Usually, it points to the terminal screen.
0 Doubts's