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
#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;
}
Comments
Leave a comment