Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

πŸ”· Square Star Pattern πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Column-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Row-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; ...

C++ Inline Function Example

C++ Inline Function Example

✅ C++ Program to Demonstrate Inline Function


#include <iostream>
using namespace std;

inline int add(int a, int b)
{
    return a + b;
}

int main()
{
    int x, y;
    cout << "Enter any two numbers:" << endl;
    cin >> x >> y;
    cout << "The sum of two numbers is:" << add(x, y) << endl;
    return 0;
}
  

πŸ“˜ Explanation:

This program demonstrates the use of an inline function in C++. An inline function is a function that is expanded in line when it is called, instead of performing a normal function call.

The function add() is declared using the inline keyword. When this function is called inside main(), the compiler replaces the function call with the actual function code.

Inline functions are generally used for small functions to reduce the overhead of function calls and improve execution speed.

🧾 Sample Output:

Enter any two numbers:
5 7
The sum of two numbers is:12
  

πŸ”‘ Keywords:

C++ inline function, inline function example, C++ add function, C++ functions, C++ basics, compile time optimization

πŸ” Search Description:

Learn inline functions in C++ with a simple program that adds two numbers. This example explains how inline functions work and when to use them.

πŸ“Œ Hashtags:

#CPlusPlus #InlineFunction #CPPBasics #Programming #Coding #1printf

Comments

Popular Posts

πŸŒ™