0% found this document useful (0 votes)
33 views1 page

Tutorial 3 - Header Files and Functions

1. Header files contain function prototypes and macro definitions needed by multiple source files in a program. They allow for modularity and reusability. 2. Include guards are used to prevent a header file from being included multiple times in a source file. This prevents function declarations from being multiplied. 3. Functions are blocks of code that perform a specific task and can be reused. They accept parameters and return values.

Uploaded by

Aakash Bathla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views1 page

Tutorial 3 - Header Files and Functions

1. Header files contain function prototypes and macro definitions needed by multiple source files in a program. They allow for modularity and reusability. 2. Include guards are used to prevent a header file from being included multiple times in a source file. This prevents function declarations from being multiplied. 3. Functions are blocks of code that perform a specific task and can be reused. They accept parameters and return values.

Uploaded by

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

Tutorial 3 Functions and Header Files

Self Review Questions 1. What are header files? Explain its purpose. 2. What are include guards? What are they used for? 3. What are functions? 4. What are reference variables in C++? How they are used in call by reference? 5. Differentiate between a. Call by Value and Call by refrence b. Normal function and Inline Functions c. Inline Functions and Macros

Programming Questions 1. An integer number is said to be a perfect number if the sum of its factors, including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a function to print all the perfect numbers between 1 and 100. 2. Write a function to calculate area and perimeter of rectangle using call by reference and print the area and perimeter in main() function. 3. To swap two numbers using call by value and call by reference using functions.

You might also like