Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem #1: Flowchart (40 marks) Draw the flowchart and write the pseudocode for an algorithm that: Reads an integer and then prints N the number

  1. Problem #1: Flowchart (40 marks)

Draw the flowchart and write the pseudocode for an algorithm that:

  • Reads an integer
  • and then prints N the number of digits in the integer
  • and the S sum of the digits.

For example, given the number 12345, it would print:

  • that there are N= 5 digits
  • with a sum S = 15

Hint:

Given the number 6761

How many digits it has?

Initially

S=0; N =0

6761 divided by ten : quotient is 676 remainder is = 1, so I have

number of digits =number of digits +1=1 , sum = sum+ 1 =1

676 divided by ten : quotient is 67 and remainder is =6, so

number of digits = number of digits+1 =2, current sum = sum + 6= 7

67 divided by ten : quotient is 6, remainder is 7,

so number of digits = number of digits +1 = 3, current sum is sum+7 =14

6 divided by 10 : quotient is 0, remainder is 6,

so number of digits = number of digits+1, sum= sum +6=20

quotient is 0 so we stop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Show the output that will display by the call show (123);

Answered: 1 week ago