LED PANEL

Google It, You'll Get It.

Monday, January 31, 2011

Counts Odds and Even Digits in a 5 Digit Number

#include<'stdio.h'>
main()
{
long numb, rem, i, temp = 0, sum, in, count = 0, even=0, odd=0;
printf("Input a 5 digit number \n");
scanf("%ld",&numb);
i = 1;

//printf("Input a digit \n");
//scanf("%ld",&in);

printf("\n");
while(i<=5)
{
temp=temp*10;
rem=numb%10;
//checking
if(rem%2>0)
odd++;
else
even++;

//if(rem==in)
//count++; //c= rem, numb =a
temp=temp+rem;
sum=sum+rem;
i++;
rem=0;
numb=numb/10;

}


//printf("%ld appears in here for %ld time \n",in,count);
printf("Total No. of Odd numberz : %ld \n",odd);
printf("Total No. of Even numberz : %ld \n",even);



// printf("inverse is %ld",temp);

}

No comments:

Post a Comment