Saturday 11 November 2017

C Program to Count the Number of Trailing Zeroes in Integer


Code:

#include stdio.h>

void main()
{
    int j = 31, i, count = 0;
    unsigned int num;
    int b[32] = {0};

    printf("enter the number:");
    scanf("%d", &num);
    while (num != 0)
    {
        if (num & 1 == 1)
        {
            break;
        }
        else
        {
            count++;
            num = num >> 1;

        }
    }
    printf("\n%d", count);
}

Output:

enter the number:128
7

More C Programs:











100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...