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 to Check Even or Odd Using Inline Function
C++ Program to Check Even or Odd Using Inline Function
#include <iostream>
using namespace std;
inline bool isEven(int n)
{
return (n % 2 == 0);
}
int main()
{
int n;
cout << "Enter a number: ";
cin >> n;
if(isEven(n))
cout << "Even number";
else
cout << "Odd number";
return 0;
}
π Explanation:
This program demonstrates the use of an inline function in C++ to check whether a given number is even or odd.
The function isEven() is declared using the inline keyword.
It returns true if the number is divisible by 2, otherwise it returns
false.
Inline functions are preferred for small logical operations because they help reduce function call overhead and improve performance.
π§Ύ Sample Output:
Enter a number: 6 Even number
π Keywords:
C++ inline function, even odd program, C++ number checking, inline function example, C++ basics
π Search Description:
Learn how to check whether a number is even or odd in C++ using an inline function. This program explains the concept with example output.
π Hashtags:
#CPlusPlus #InlineFunction #EvenOdd #CPPBasics #Programming #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