Answer to Question #193355 in C for sai

Question #193355

Write a program in c which counts for the number of digits in an integer number being entered by user using: do While loop


1
Expert's answer
2021-05-14T04:18:02-0400
/*
 * If need use do ... while only
*/

#include <stdio.h>

void main()
{
    int num, digit = 0;

    printf("Input number: ");
    scanf("%d", &num);

    do
        digit += !!num;
    while (num /= 10);

    printf("Digits: %d\n", digit);
}

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