20)C PROGRAM TO COUNT THE NUMBER OF DIGITS
LOGIC:- In this program "/" operator are used.
(a)enter any number. for example n= 2351 clearly it contains 4 no. of digits
(b)now divide number by 10 using "/" operator , it gives quotient which is 235 and count this operation =1 i.e increment count
(c)again divide the new number which is 235 by 10 now we have 23. and count becomes 2 after increment.
(d)similarly do until the quotient become 1, i.e while loop required
EXAMPLE:-
LOGIC:- In this program "/" operator are used.
(a)enter any number. for example n= 2351 clearly it contains 4 no. of digits
(b)now divide number by 10 using "/" operator , it gives quotient which is 235 and count this operation =1 i.e increment count
(c)again divide the new number which is 235 by 10 now we have 23. and count becomes 2 after increment.
(d)similarly do until the quotient become 1, i.e while loop required
EXAMPLE:-
Comments
Post a Comment