Chapter:

C-Programs-on-integers

C Program to Compute 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 <stdio.....

Show More

All Chapters

View all Chapter and number of question available From each chapter from C-programming-