100 likes | 206 Views
In this presentation on C Header files, we will learn what are C Header Files and why we need header files? We'll look at the types of header files and how to create our own header files. You will understand through interactive examples and code snippets.<br> <br>Below are the topics we will be discussing in this video:<br>1. Why We need Header Files?<br>2.u200b C Header File<br>3.u200b Types of Header Files<br>4. How to create your own header file<br>5.u200b Examples header files<br><br>ud83dudc49To know about C programming, visit: https://www.simplilearn.com/c-plus-plus-programming-for-beginners-article
E N D
What’s in it for you ? Why we need Header files ? C++ header file Types of header files How to create your own header file Examples header files
Why we need header files ? Header files allow us to assemble all predefined functions in a single library It helps in taking input and displaying output in the program and many more functionalities It reduces the complexity and number of lines of code
C++ header file Header files are the set of libraries that contains predefined functions like cin, cout that are being used while writing a program Syntax : #include<filename.h>
Types of header files There are two types of header files : Pre-existing header files : These are those files which are already available in C++ compiler User-defined header files : These are those files which are defined by users and can be imported using include
How to create your own header file • First of all, we write the C++ code, which we want to use whenever we want • Now save the file with “.h ” extension Step 1 : int product(int x, int y) { return (x*y); }
How to create your own header file Step 2 : • With the help of pre-processor “#include”, add the header file in the program #include<iostream> #include<product.h> int main() { int x=9; int y=5; cout<<product(x,y)<<endl; } Output: 45
Examples of header files Some C++ header files are : #include<iostream> : Used in order to read or write standard input and output streams #include<iomanip.h> : Used in the manipulation of input/output statements #include<fstream.h> : Used to write information to files and read information from files