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