Answer to Question #292077 in C for Nickleodeon20

Question #292077

5. 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.


1
Expert's answer
2022-01-30T07:29:17-0500
#include<stdio.h>

 

int main()

{

      int num, temp, count = 0;

      printf("\nEnter a Number:\t");

      scanf("%d", &num);

      temp = num;

      while(num >= 0)

      {

            if(num%10 == 0)

            {

                  count++;

                  num = num / 10;

            }

            else

            { 

                  break;

            }
      }       

      printf("\nNumber of Trailing Zeros in %d = %d\n", temp, count);

      return 0;

}
Enter a number: 2000
Number of Trailing Zeros in 2000 = 3

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