Showing posts with label ODD OR EVEN. Show all posts
Showing posts with label ODD OR EVEN. Show all posts

Tuesday, March 10, 2015

Odd or even

Algorithm
Step 1 : Start
Step 2 : Read number
Step 3 : If number divisible by 2 then
Print "Number is Even"
Step 3.1 : else
Print "Number is Odd"
Step 4 : Stop

Program (oddeven.sh)
# Odd or even using if-else
echo -n "Enter a non-zero number : "
read num
rem=`expr $num % 2`
if [ $rem -eq 0 ]
then
echo "$num is Even"
else
echo "$num is Odd"
fi

Monday, January 12, 2015

PROBLEM SOLVING USING DECISION MAKING

PROGRAM:

#include<stdio.h>
main()

{
int a,rem;

printf("Enter a Number\n"); scanf("%d",&a); 
rem=a%2;
if(rem==0)
printf("The Given Number is Even");

else
printf("The Given Number is Odd");

}

OUTPUT:

Enter a Number 13


The Given Number is Odd