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++ Program Using Inline Function (Square / Multiplication)

C++ Inline Function Example – Square Using Inline Function

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

Comments

Popular Posts

πŸŒ™