Está en la página 1de 4

DISCUSSION Discuss what function in C programmes

A function in C language is a block of code that performs a specific task. It has a name and it is reusable i.e. it can be executed from as many different parts in a C Program as required. It also optionally returns a value to the calling program So function in a C program has some properties discussed below. Every function has a unique name. This name is used to call function from main() function. A function can be called from within another function. A function is independent and it can perform its task without intervention from or interfering with other parts of the program. A function performs a specific task. A task is a distinct job that your program must perform as a part of its overall operation, such as adding two or more integer, sorting an array into numerical order, or calculating a cube root etc. A function returns a value to the calling program. This is optional and depends upon the task your function is going to accomplish. Suppose you want to just show few lines through function then it is not necessary to return a value. But if you are calculating area of rectangle and wanted to use result somewhere in program then you have to send back (return) value to the calling function.

Function A Function B Function C

Explain what the type of function in C programmes 1. Functions with no arguments and no return values. No data transfer between the calling function and the called function. Function has no arguments it does not receive any data from the calling function. A function that does not return any value to calling function. Example //Example ************ void DTK2A (void) { } 2. Functions with arguments and no return values. Data communication between the calling function and the arguments to the called function and the called function does not return any values to the calling function. Example //Example ************ void POLISAS (int x) { } 3. Functions with arguments and return values. This function will send arguments from the calling function to the called function and expects the result to be returned back from the called function back to the calling function. Example //Example ************ char JKE (float z) { char i; return i; }

CONCLUSION From this experiment,we learned how to know the methods of using built-in functions and we also learned how to use several built-in functions available to develop a C program.Next,we also learned method of user-defined functions and develop user defined function that can be called in different methods.Finally we learned The type of functions,for example ,Functions with no arguments and no return values,Functions with arguments and no return values,Functions with arguments and return values,Functions that return multiple values and Functions with no arguments and return values.

PROCEDURES STEP 1 PRE-DEFINED FUNCTIONS Math.h header file had been used as a functions to solve the following mathematical equations: Note:[Save as lab7_1.cpp] I. II. III. IV. b=8a3+3a2-5a+2 c=3e-2+sin 2a5 d=a5log10a+3a5 e=a+6ln a5

The suitable value had been given for our Output STEP 2 CONSTRUCT A C++ HEADER FILE C++ header file had been created that calculates the fifth power of a number and returns the results. The file had been saved with extension.h.The new header had been used to execute the fifth power in step 1b,c and d in the same way that we use the math.h header file to solve the arithmetic equations in step 1 above. [NOTE:Do not use (a,5) anymore] Note:header file [saved as H1.h] Step2[saved as Lab7_2.cpp] STEP 3 CONSTRUC A PERSONAL HEADER FILE (START) The personal our heaeder file (start) had been builder that can be used as our trademark and our own special features for this assignment and others in future.The header file had been saved in our regular folder and rebuild the source code in step 2 to use header file. NOTE:header file [saved as start.h] Step 3 [saved as lab7_3.cpp STEP 4 CONSTRUCT A PERSONAL HEADER FILE (END) The personal our heaeder file (end) had been builder that can be used as our trademark and our own special features for this assignment and others in future.The header file had been saved in our regular folder and rebuild the source code in step 3 to use header file. NOTE:header file [saved as end.h] Step 4 [saved as lab7_4.cpp

También podría gustarte