Computer Science, asked by Anonymous, 6 hours ago

\bf\large\underline{Question :- }

* Write C++ programs for the following

1) Input a number from the user and check if it is an even Or odd number.

2) Input a character and check if it is a constant or a vowel.

⇢No irrelevant answers..!!
⇢ No links !!
⇢ Spam will be reported
_____________________

Answers

Answered by Kalihacker
9

Answer:

1)

#include <iostream>

using namespace std;

int main() {

int number;

cout << "Enter a number: ";

cin >> number;

if (number%2==0) {

cout << "The number is even" << endl;

} else {

cout << "The number is odd" << endl;

}

}

Answered by djalokprofreefire
4

To understand this example, you should have the knowledge of the following C++ programming topics:

C++ if, if...else and Nested if...else

C++ Ternary Operator

Integers that are perfectly divisible by 2 are called even numbers.

And those integers that are not perfectly divisible by 2 are not known as odd numbers.

To check whether an integer is even or odd, the remainder is calculated when it is divided by 2 using modulus operator %. If the remainder is zero, that integer is even if not that integer is odd.

Example 1: Check Whether Number is Even or Odd using if else

#include <iostream>

using namespace std;

int main() {

int n;

cout << "Enter an integer: ";

cin >> n;

if ( n % 2 == 0)

cout << n << " is even.";

else

cout << n << " is odd.";

return 0;

}

hope it helps please mark me brainleast answer

thank you so much for following me

Similar questions