0% found this document useful (0 votes)
8 views12 pages

C Programming

The document provides an overview of functions in C programming, including their definition, types, and examples. It distinguishes between library functions, which are predefined and cannot be modified, and user-defined functions, which are customizable by the user. The document also outlines four types of functions based on their arguments and return values, emphasizing the importance of functions in writing efficient and maintainable code.

Uploaded by

Ámrit Dangi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views12 pages

C Programming

The document provides an overview of functions in C programming, including their definition, types, and examples. It distinguishes between library functions, which are predefined and cannot be modified, and user-defined functions, which are customizable by the user. The document also outlines four types of functions based on their arguments and return values, emphasizing the importance of functions in writing efficient and maintainable code.

Uploaded by

Ámrit Dangi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

FUNCTIONS

Bachelor of Information Technology I Semester

Amrit Dangi
Binayak Sijapati
Sushant Khadka
CONTENTS
• Introduction to Function 1
• Library Function 2
• User define Function 3
• Types of Functions(4-types) 4-8
• Conclusion 9
INTRODUCTION

• A function is a self-contained subprogram meant to do well-defined


task.

• It helps to divide a complex program into chunks, each of which


performs specific tasks.

• Use of functions avoids repetition of code & helps in organizing


code making it reusable & easier to debug.

1
LIBRARY FUNCTION

• Predefined functions provided by C standard library.

• Declared in header files e.g.stdio.h, string.h.

• Can be reused across multiple programs without rewriting the code.

• Cannot be modified by users.

• E.g.. printf() , scanf(), strlen() etc.

2
USER DEFINED FUNCTIONS

• Defined by users for specific tasks.

• Declared in the program by users.

• Need to be rewritten or copied into other programs for reuse.

• Can be fully customized by users as requirements.

• E.g. add(), factorial(), swapArray() etc.


3
TYPES OF FUNCTIONS

1. With no argument and no return value

2. With no arguments and a return value

3. With arguments and no return value

4. With arguments and a return value

4
1.No Argument and No Return

• The function does not take any input parameters.

• The function does not return any value (void is used as the return type).

Syntax
void functionName() {
// Function code
}

5
2.No Argument and a Return Value

• The function does not take any input parameters

• The function returns a result using the return statement.

Syntax
returnType functionName() {
// Code
return value;
}

6
3.Argument and No Return Value

• The function accepts input parameters


• The function performs an operation but does not return anything (void is used)

Syntax
void functionName(dataType param1, dataType param2, ...) {
// Function body (performs an operation)
}

7
4. Argument and a Return Value

• The function accepts input parameters.

• The function processes the inputs and returns a result using return.
Syntax
returnType functionName(dataType param1, dataType param2, ...) {
// Function logic
return value;
}

8
CONCLUSION

By effectively using functions, we can write efficient, structured, and maintainable C


programs. Mastering functions helps in building complex applications while keeping
the code clean and manageable.

9
QUESTIONS/QUERIES…

10

You might also like