Check whether number is positive, negative, even or odd
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("enter the no");
scanf("%d",&n);
if(n>0)
{
printf("\nnumber is +ve");
if(n%2==0)
printf("\n number is even");
else
printf("\n number is odd");
}
if(n<0)
printf("\n number is -ve");
getch();
}
#include<conio.h>
void main()
{
int n;
clrscr();
printf("enter the no");
scanf("%d",&n);
if(n>0)
{
printf("\nnumber is +ve");
if(n%2==0)
printf("\n number is even");
else
printf("\n number is odd");
}
if(n<0)
printf("\n number is -ve");
getch();
}
C program to check odd or even
ReplyDeleteIn general Even numbers are those which are divisible by 2, and which numbers are not divisible 2 is called odd numbers.
We can easily write even odd program in c programming.
C++ Program Even and Odd Elements in Array
ReplyDeletethis is my home work thanks
Very Nice Post visit nice example also Even odd example in java
ReplyDeleteVisit nice example Even odd logic
ReplyDelete