Write
an algorithm ,a program and draw a
flowchart to calculate the sum of
digits of any number given by a user.
Step2: Divide the value of n by 10 and assign it to variable x
Step3: Multiply the value of x by 10 and assign it to variable t
Step4: Subtract the value of t by value of n and assign it to variable c
Step5: Add the value of c & value of sum and assign it to variable sum
Step6: Assign the value of x to variable n
Step7: if x is not equal to zero then go back to step2
Step8: Display “the sum is “, value of variable sum
Step9: Stop
Flowchart
To write the program in C,
To create the SumOfDigits App in MIT App Inventor,
Comments
Post a Comment