# How to make a program to find out odd or even numbers?

asked Jun 19, 2018 2 flags
closed Jun 11
Please give me a easy learning script as a example.
closed with the note: Closing question, since it has been answered

+1 vote
answered Jun 20, 2018 by (200 points)

#include <iostream>

using namespace std;

int main()
{
int number;

cout<<"Introduce a number:";
cin>>number;
if (number %2 == 0) { //Residue cero, then even
cout<<"Even number"<<endl;
} else {
cout<<"Odd  number"<<endl;
}
return 0;
}

commented Feb 26, 2019 by (100 points) 1 flag
you don't need equality operator
commented Mar 3 by anonymous
you don't but it is good programming to write it explicitly
commented May 3 by (100 points)
is the above program is a c prgm???
the header file used is iostream which is  used for the C programming
commented Jun 11 by (9,990 points)
The above is not C, but C++.
"iostream" is a C++ library. In C you should use "stdio.h".
+1 vote
answered Jun 21, 2018 by (160 points)
#include<stdio.h>

int main()

{

int a;

printf("enter the no's to check odd or even");

scanf("%d",&a);

if(a%2==0)

{

printf("the no is even");

}

else

{

printf("the no is odd");

}

return 0;

}
+1 vote
answered Jun 21, 2018 by (160 points)
#include<stdio.h>

void main()

{

int a;

printf("enter a number");

scanf("%d",&a);

a%2==0?even:odd;

}
commented Feb 26, 2019 by (100 points)
it does give an error , doesn't it?
answered Jun 21, 2018 by (140 points)
#include<iostream>
using namespace std;
int
main ()
{
int x;
cout << "enter the number.." << endl;
cin >>x;
if(x%2==0)
{
cout << "the number is even number... "<<endl;
}
else
{
cout << "the number is odd number..." <<endl;

}
}
answered Jun 21, 2018 by anonymous
# include<iostream>

using namespace std;

int main()

{

int  num;

cout<<"Enter Number "<<endl;

cin>>num;

if(num %2==0)

cout<<"even Number "<<endl;

else

cout<<"odd Number"<<endl;

}
answered Jun 21, 2018 by (140 points)
include<stdio.h>

int main()

{

int n;

printf("Enter the number:");

scanf("%d",&n);

if(n%2=0)

{
printf("the number is even: %d",n);

}

else

{

printf("The number is odd:");

}

}
answered Jun 22, 2018 by (140 points)
#include<stdio.h>

void main()

{

int n;

scanf("%d",&n);

if(n%2==0)

printf("The given number is an Even Number");

else

printf("The given number is an Odd Number");
answered Jun 24, 2018 by (210 points)
#include<stdio.h>

int main()

{

int a=0;

printf("Enter the value of a :\n");

scanf("%d",&a);

if(a%2==0)

printf("The number is even.\n");

else

printf("The number is odd\n");

return 0;
commented Feb 25 by (140 points)
dont forget the brackets.... pls add it
answered Jun 25, 2018 by (140 points) 1 flag

#include<stdio.h>

int main()

{

int a;

printf( "enter the number to be check:");

scanf("%d",&a);

if(a%==0)

{

printf("the entered number is even");

}

else

{

printf("the entered number is odd");

}

return 0;

}

+1 vote
answered Jun 25, 2018 by vaishnavi
#include<stdio.h>

void main()

{

int i;

for(i=1;i<=10;i++)

if(i%2==0)

{

printf("even numbers");

printf("%d",i);

}

else

{

printf("odd numbers");

}

}