Computer Science, asked by chatmihir27, 9 months ago

Write a program in C++ to input a number and check whether it is even or odd. Write down sample output also for your program. in Dev c++​

Answers

Answered by imtiyazallam
2

Answer:

#include<iostream>

using namespace std;

int main(){

   int num;

   cout << "Enter a number: ";

   cin >> num;

   if(num % 2 == 0) {

       cout << "It is a even number.";

   } else {

       cout << "It is a odd number.";

   }

}

I don't have dev C++ so I used VS Code. Codes of C++ is same.

Attachments:
Answered by anindyaadhikari13
1

\star\:\:\:\sf\large\underline\blue{Question:-}

  • Write a program in C++ to input a number and check whether it is even or odd.

\star\:\:\:\sf\large\underline\blue{Source\:Code:-}

#include <iostream.h>

using namespace std;

int main()

{

int n=0;

cout << "Enter a number: ";

cin >> n

if(n%2==0)

cout << "Number is Even. ";

else

cout << "Number is Odd. ";

return 0;

}

\star\:\:\:\sf\large\underline\blue{Output:-}

Enter a number: 59

Number is Odd.

Attachments:
Similar questions