c program to count the number of odd and even digits in an integer


http://stackoverflow.com/a/38181488/6393408
#include<stdio.h> 
#include<conio.h>

void main()

{    

       int nodd,neven,num,digit ; 
       clrscr();



       printf("Count number of odd and even digits in a given integer number ");

       scanf("%d",&num);

                nodd = neven =0; /* count of odd and even digits */

                while (num> 0)

                    {

                        digit = num % 10; /* separate LS digit from number */

                        if (digit % 2 == 1)

                           nodd++;

                        else neven++;

                               num /= 10; /* remove LS digit from num */

                    }

                        printf("Odd digits : %d Even digits: %d\n", nodd, neven);

                        getch();

Comments

Popular posts from this blog

MongoDB shell version v4.4.4 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: No connection could be made because the target machine actively refused it. : connect@src/mongo/shell/mongo.js:374:17 @(connect):2:6 exception: connect failed exiting with code 1

Creating Your Portfolio Website

First Backend Website