Computer Science, asked by mukeshkumar8832, 3 months ago


15 पूर्णांक संख्याओं को स्वीकार करने के लिए C++ में एक प्रोग्राम लिखें फिर गणना
और प्रदर्शन करें तथा 15 पूर्णांकों में से विषम और सम संख्या की गिनती और योग को
प्रदर्शित करें।
Write a program in C++ to accept 15 integer numbers then calculate and
display count and sum of odd & even numbers out of 15 given numbers.​

Answers

Answered by Anonymous
5

\huge\mathfrak\red{answer}

An integer number which is evenly divisible by 2 is called even number. When I say evenly divisible, it means that if we divide the even number by 2, it yields no remainder. For example, 2, 4, 6, 8 …are even numbers.

An integer number which yields a remainder when divided by 2 is known as odd number. For example, 3, 5, 7, 9 are odd numbers.

Lets write a program to check even odd numbers

Example: Program to check whether the entered number is even or odd

To understand this program, you should have the knowledge of if-else and user-defined functions in C++.

include <iostream>

using namespace std;

bool checkEvenOdd(int num);

int main(){

int num;

bool isEven;

cout<<"Enter any number: ";

//Storing the entered value in variable num

cin>>num;

//Calling the function that checks even odd

isEven = checkEvenOdd(num);

if(isEven)

cout<<num<<" is an even number";

else

cout<<num<<" is an odd number";

return 0;

}

/* This function checks whether the passed number is even

* or odd. If the number is even then this function returns

* true else it returns false.

*/

bool checkEvenOdd(int num){

bool b;

/* If number is perfectly divisible by 2 then it is

* an even number else it is an odd number

*

*/

if (num % 2 == 0)

b=true;

else

b=false;

return b;

}

{Please do not report if the answer is wrong, we have tried our best to give you the correct answer}

Answered by ItzShruti14
0

Answer:

An integer number which is evenly divisible by 2 is called even number. When I say evenly divisible, it means that if we divide the even number by 2, it yields no remainder. For example, 2, 4, 6, 8 …are even numbers.

An integer number which yields a remainder when divided by 2 is known as odd number. For example, 3, 5, 7, 9 are odd numbers.

Lets write a program to check even odd numbers

Example: Program to check whether the entered number is even or odd

To understand this program, you should have the knowledge of if-else and user-defined functions in C++.

include <iostream>

using namespace std;

bool checkEvenOdd(int num);

int main(){

int num;

bool isEven;

cout<<"Enter any number: ";

//Storing the entered value in variable num

cin>>num;

//Calling the function that checks even odd

isEven = checkEvenOdd(num);

if(isEven)

cout<<num<<" is an even number";

else

cout<<num<<" is an odd number";

return 0;

}

/* This function checks whether the passed number is even

* or odd. If the number is even then this function returns

* true else it returns false.

*/

bool checkEvenOdd(int num){

bool b;

/* If number is perfectly divisible by 2 then it is

* an even number else it is an odd number

*

*/

if (num % 2 == 0)

b=true;

else

b=false;

return b;

}

Similar questions