Answer to Question #292083 in C for Nickleodeon20

Question #292083

Count the Trail

by CodeChum Admin

Help, I'm lost!


I usually find my way around here but I somehow lost my glasses along the way. I can easily get back home as long as I can tell how many zeroes I left in my trail. Would you mind telling me how many zeroes are trailing?


Note: Trailing zeroes are the zeroes found at the right side of a number.

Input


1. The number to be evaluated


Constraints

This can only be a positive integer.

Output

The first line will contain a message prompt to input the number to be evaluated.

The second line will contain the number of trailing zeroes.

Enter·the·number:·24100
Trailing·zeroes·=·2
1
Expert's answer
2022-01-31T18:32:19-0500
#include<stdio.h>
#include<stdlib.h>
int main(){
   int number, i, trail = 0, size;
   printf("Enter a number\n");
   scanf("%d",&number);
   size = sizeof(number) * 8;
   for(i = 0; i < size; i++){
      if((number >> i) & 1) {
         break;
      }
      trail++;
   }
   printf("Number of trailing ZERO is = %d", trail);
   return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS