Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
225 views

Write An Algorithm and Draw A Corresponding Ow Chart To Print The Sum of The Digits of A Given Number

The document describes an algorithm and flowchart to calculate the sum of digits in a number. It presents the pseudo code which initializes a sum variable to 0, uses a while loop to iterate through each digit of the number, calculates the remainder when the number is divided by 10 to extract the digit, adds this to the sum, and divides the number by 10. The flowchart shows the steps of taking input, initializing sum, extracting digits in a loop and adding to sum, and outputting the final sum.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
225 views

Write An Algorithm and Draw A Corresponding Ow Chart To Print The Sum of The Digits of A Given Number

The document describes an algorithm and flowchart to calculate the sum of digits in a number. It presents the pseudo code which initializes a sum variable to 0, uses a while loop to iterate through each digit of the number, calculates the remainder when the number is divided by 10 to extract the digit, adds this to the sum, and divides the number by 10. The flowchart shows the steps of taking input, initializing sum, extracting digits in a loop and adding to sum, and outputting the final sum.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

7/14/2021 Write algorithm & flowchart to print sum of digits of number | Computer Science Simplified - A Website for IGNOU

or IGNOU MCA & BCA Students f…

Write an algorithm and draw a corresponding flow


chart to print the sum of the digits of a given number
By Gangadhar Koppella
| May 30, 2014 0 Comment

Write an algorithm and draw a corresponding flow chart to print the sum of the digits of a given number 10m
Dec2005 

An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in
pseudo code – something resembling C language or Pascal, but with some statements in English rather than within
the programming language

1. A sequential solution of any program that written in human language, called algorithm.
2. Algorithm is first step of the solution process, after the analysis of problem, programmers write the algo-
rithm of that problem.

Pseudo code: 

Input a Number
Initialize Sum to zero
While Number is not zero
               Get Remainder by Number Mod 10
               Add Remainder to Sum
               Divide Number by 10
Print sum 

Detailed Algorithm:

Step 1:  Input N

Step 2:  Sum = 0

Step 3:  While (N != 0)

cssimplified.com/c-cpp-programming-data-structure/write-an-algorithm-and-draw-a-corresponding-flow-chart-to-print-the-sum-of-the-digits-of-a-given-n… 1/3
7/14/2021 Write algorithm & flowchart to print sum of digits of number | Computer Science Simplified - A Website for IGNOU MCA & BCA Students f…

                        Rem = N % 10;

                        Sum = Sum + Rem;

                        N = N / 10;

Step 4:  Print Sum

 Flowchart:-

Q Write a recursive program to find the G.C.D. of the two given numbers. 10m Dec2005 

Solved program can be found on this link http://cssimplified.com/c-programming/a-c-program-to-find-the-gcd-of-


given-numbers-using-recursion

Category: C Theory C, C++Programming & Data Structure


Tags: algorithm , chart , corresponding , Digits , draw ,
flow , given , number , print , sum , Write

cssimplified.com/c-cpp-programming-data-structure/write-an-algorithm-and-draw-a-corresponding-flow-chart-to-print-the-sum-of-the-digits-of-a-given-n… 2/3
7/14/2021 Write algorithm & flowchart to print sum of digits of number | Computer Science Simplified - A Website for IGNOU MCA & BCA Students f…
This site uses Akismet to reduce spam. Learn how your comment data is processed.

Iconic One Theme | Powered by Wordpress

cssimplified.com/c-cpp-programming-data-structure/write-an-algorithm-and-draw-a-corresponding-flow-chart-to-print-the-sum-of-the-digits-of-a-given-n… 3/3

You might also like