#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int i = 0, j = 0, len, sum = 0;
char ch[1000];
printf("Enter any Binary Number : ");
gets(ch);
len = strlen(ch);
for(i=len-1; i>=0; i--)
{
sum = sum + (ch[i] * pow(2,j));
j++;
}
if(sum%2 == 0)
{
printf("Even Number\n");
}
else if(sum%2 != 0)
{
printf("Odd Number\n");
}
return 0;
}
#include<string.h>
#include<math.h>
int main()
{
int i = 0, j = 0, len, sum = 0;
char ch[1000];
printf("Enter any Binary Number : ");
gets(ch);
len = strlen(ch);
for(i=len-1; i>=0; i--)
{
sum = sum + (ch[i] * pow(2,j));
j++;
}
if(sum%2 == 0)
{
printf("Even Number\n");
}
else if(sum%2 != 0)
{
printf("Odd Number\n");
}
return 0;
}
Comments
Post a Comment