Write a program of inline function, C/C++ Programming

Assignment Help:

Here is a program that uses an inline function to compute and return the absolute value of its input argument.

# include

inline int abs(int x)

{

                 return x <0? -x : x ;

}

void main( )

                {

                  for (int i=-2 ; i<2 ; ++i)

                   {

           int value = abs(i) ;

           printf ("Absolute value of %+d = %+d\n",i, value);

         } 

      }

The output is:

Absolute value of -2 =+2

Absolute value of -1 =+1

Absolute value of +0 =+0

Absolute value of +1 =+1

When the call to the abs ( )  function is encountered, the compiler, instead of making a function call, generates this assembly code.

 


Related Discussions:- Write a program of inline function

Software reverse engineered, Project Description: I have software writte...

Project Description: I have software written with VB that i helped design, but now the original author died,(Neil Tromp), and the software ended up in the hands of someone else!

Simple object-oriented program, This assignment is to be undertaken individ...

This assignment is to be undertaken individually - no group work is permitted. Background information This assignment is an exercise in simple object-oriented programming and, acco

Decode, Problem Description Smugglers are becoming very smart day by day. N...

Problem Description Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new techn

Define the arithmetic operators in c language, Define the Arithmetic Operat...

Define the Arithmetic Operators in c Language? There are five arithmetic operators in C and they are Operator             Purpose +                        Addition -

Decode the Code, Smugglers are becoming very smart day by day. Now they hav...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Ascii string related, A string S is said to be "Super ASCII", if it contain...

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

What is the maximum number of constructors, Question: (a) (i) Explain...

Question: (a) (i) Explain how class members can be accessed when using objects of the class. Use a suitable example to illustrate your answer. (ii) Explain how the privat

Program, First line starts with T, number of test cases. Each test case T c...

First line starts with T, number of test cases. Each test case T contains a necklace (N).

Define the logical operators in c language, Define the Logical Operators in...

Define the Logical Operators in c language? The Logical operators deals with the ways the relationships are able to connected. C has the following three logical operators

Oop, evolutio of object oriented programing

evolutio of object oriented programing

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