Computer Science, asked by gbunty7166, 1 year ago

Write a fortran program to find the digits of a number and the sum the digits

Answers

Answered by Anonymous
0
First logic is the easiest and is the common to think. It uses loop to count number of digits. To count number of digits divide the given number by 10 till number is greater than 0. For each iteration increment the value of some countvariable.

Step by step descriptive logic to count number of digits in given integer using loop.

Input a number from user. Store it in some variable say num.

Initialize another variable to store total digits say digit = 0.

If num > 0 then increment count by 1i.e. count++.

Divide num by 10 to remove last digit of the given number i.e. num = num / 10.

Repeat step 3 to 4 till num > 0 or num != 0.

Answered by Anonymous
1

Input a number from user. Store it in some variable say num. Initialize another variable to store total digits say digit = 0. If num > 0 then increment count by 1i.

Similar questions