Search This Blog
Welcome to 1printf(), your ultimate destination for C, C++, Linux, Data Structures, and Microcontroller programming! ๐ ๐นLearn advanced coding techniques in C& C++ ๐นMaster Linux internals & shell scripting ๐นDeep dive into Data Structures & Algorithms ๐นExplore Embedded Systems & Microcontrollers (8051,UART, RTOS) ๐นGet hands-on coding tutorials, project ideas,and interview preparation tips Whether you're a beginner or an experienced programmer, this channel will help you
Featured
- Get link
- X
- Other Apps
C++ Program Using Inline Function (Square / Multiplication)
C++ Program Using Inline Function (Square / Multiplication)
#include <iostream>
using namespace std;
inline int squar(int a, int b)
{
return a * b;
}
int main()
{
int x, y;
cout << "Enter any two numbers:" << endl;
cin >> x >> y;
cout << "the squar of " << x << " and " << y
<< " is " << squar(x, y) << endl;
return 0;
}
๐ Explanation:
This program demonstrates the use of an inline function in C++ to perform multiplication of two numbers.
The function squar() is declared using the inline keyword.
When this function is called, the compiler attempts to replace the function call
with the actual function code to reduce function call overhead.
Inline functions are best suited for small and frequently used functions, as they improve execution speed by avoiding repeated function calls.
๐งพ Sample Output:
Enter any two numbers: 4 5 the squar of 4 and 5 is 20
๐ Keywords:
C++ inline function, inline multiplication, C++ square program, inline function example, C++ basics, function optimization
๐ Search Description:
Learn how inline functions work in C++ with a simple program that multiplies two numbers. Includes explanation, syntax, and example output.
๐ Hashtags:
#CPlusPlus #InlineFunction #CPPBasics #Programming #Coding #1printf
Popular Posts
C++ Program for Hybrid Inheritance (All Types Together)
- Get link
- X
- Other Apps
C++ Program for Function Overloading Example
- Get link
- X
- Other Apps
Comments
Post a Comment