Inline functions, C/C++ Programming

Assignment Help:

Inline functions, C++ provides inline functions to help reduce function_call overhead especially for small functions. The

qualifier inline before function's return type in the function informs the computer to generate a copy of the functions code in place, to avoid a function call.

The disadvantage is that multiple copies of function code are inserted in the program (thus making it larger) rather than a single copy of the function to which control is passed each time the function is called.
The compiler can ignore the inline qualifier especially for large functions

Example:

Write a C++ program that prompts for the radius of a circle, and which is passed to an inline function to compute and return the area of a circle. Your program then displays the computed value.

#include 

#include 
#include 
using namespace std;

inline double computearea(int);
int main()

{

int radius; 

double area;

cout<<"Enter the radius of the circle"<>radius;

area=computearea(radius);

cout<<"The area of the circle is:"

<return  0;

}

double computearea(int r)
{

const float    PI=3.142;
     
return PI*pow(r,2);
 }


Related Discussions:- Inline functions

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Pebble merchant, there is a pebble merchant. he sells the pebbles,that are ...

there is a pebble merchant. he sells the pebbles,that are used for shining the floor.his main duty is to take the length of the room side but he sometines mistakes doing that and m

C program to check factorial, C Program to check FACTORIAL   main() ...

C Program to check FACTORIAL   main() {             int i,j,m,fact,sum=0;           clrscr();           printf("ENTER THE NO.: ");           scanf("%d",&m);

Flowchart.., flowchart of c programing to check the given number is prime o...

flowchart of c programing to check the given number is prime or not

C++, Write a program to find the area under the curve y = f(x) between x = ...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Advanced input - output routines, Although we can handle most I/O routines ...

Although we can handle most I/O routines with getc and putc , there are file versions of fgets, fputs, fprintf and fscanf . The syntax is       fgets(stringname,n,filename);   Th

Minimum total number of shelves, At a shop of marbles, packs of marbles are...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Describe problem with runtime type identification?, Describe problem with R...

Describe problem with Runtime type identification? A: The run time kind identification comes at cost of performance penalty. Compiler maintains class.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd