Login to ask a question from C Programs on integers

C Program to Compute the Sum of Digits in a given Integer:

This is a C program to compute the sum of digits in a given integer.

Problem Description

This program computes the sum of digits in a given integer.

Problem Solution
  • Take the integer as input.

  • Divide the input integer by 10, obtain its remainder and quotient.

  •  Increment the new variable with the remainder got at step 2.

  • Repeat the step 2 & 3 with the quotient obtained until the quotient becomes zero.

  •  Print the output and exit.

    Program/Source Code

/*

 * C program to accept an integer & find the sum of its digits

 */

#include

 

void main() Show More

Previous Question Next Question
🔗

Similar Questions

From C Programs on integers · C programming

View All
WhatsApp