adding digits of a number in c

//program to find the sum of digits:

#include<stdio.h>
int main()
{
  int num,sum=0,r,temp;
  printf("Enter the number:\n ");  //taking input from the user
  scanf("%d",&num);
  
  temp=num;           //assigning num to temporary variable
  
  while(temp!=0)
  {
    r=temp%10;
    sum=sum+r;
    temp=temp/10;
  }
  printf("\nGiven number = %d",num);
  printf("\nSum of the digits = %d",sum);
}

//code By dungriyal

4
4

                                    Enter the number
300
Given number = 300
Sum of the digits 300 = 3
&nbsp;
&nbsp;
Enter the number
16789
Given number = 16789
Sum of the digits 16789 = 31

4 (4 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
Count number of digits in a number in C sum of the digits of a number in c C program to calculate sum of digits of a number. C program to count number of digits in a number c program to compute the sum of digits in a given integer sum of even digits in a number in c Write a C program to count number of digits in any number. sum of digits c program find out integer of sum of digit in c count the number of digits in a number in c program the sum of digits of number in c C. Given Length and Sum of Digits... sum of digits using function in c how to retrieve sum of digits \of number in c print sum of digits in c count the digits of a number in c c program for adding digits of a number digit sum in c how to count number of digits in c sum of digits up to single digit in c add numbers in c how to count number of digits in a number in c c sum of all digits in number sum of individual digits in c using function count no of digits in c sum of 5 digits in c how to sum all digits in a number in c c program for sum of digits Write a program in C to calculate SUM of all digits present in a user given number. add sum of digits in c c program to calculate sum of digits of a number sum of the digit in c summing up the digits in c find the sum of digits in c program count the number of digits in c count number of digits using loop in c find digit sum of a number in c code to calculate sum of digits in c using functions add the digits of a number in c C Program to Count Number of Digits in an Integer find sum of all the digits in c sum of digits of a five digit number c program sum of digit in c c programming add 0 number digits how to take in an input of integers and sum all of the digits in c sum of all the digits of a nuymber program in c sum of numbers in a digit c Write a program to find the sum of all the digits of a number by taking n input in c Write a program to find the sum of all the digits of a number in c Write a program to find the sum of all the digits of a number. in c program to sum of digits of a number in c finding sum of digits in c printing sum of digits in c write a program to calculate sum of digits of a number in c to find the sum of digits of a number in c how to find the sum of the digits in c SUM OF DIGITS problem solution in c c program to find sum of digits of a number how to count the digits in an int c c program to count number of digits in given number to Add even digits from the given number C program Write a program to take a number and calculate the sum of digit of a number. in c C. Given Length and Sum of Digits C. Given Length and Sum of Digits.. c program to find sum of digits of a 5 digit number sum of digits in c algorithm to count number of digits in a number in c how to get the digits of an integer and sum the odd in c let total number = 5 total number = number in c how to print directly sum of digits in c how to get the sum of digits of a number in C sum of individual digits in c count the numer of digits in a int c sum digits of a number c add digits of a number in c add digits together c c program to find sum of individual digits of a given number write a c program to find sum of individual digits how to sum digits of a number in c sum of digits of 5 digit number in c c program find sum of digits sum of its digits in c Sum of digits of a number in c using for loop Program for Sum of the digits of a given number c sum of digits of the number in c add digits of intiget c program to find sum of digits of a number in c c program to add 4 digit number program to count number of digits in c sum of digits until single digit in c how to add numbers in C count the number of digits in a number in c C program to count total number of digits of an Integer c program to find sum of even digits in a given number sum of second digits of number in c wriite a c program yo count total number of digits of an intiger number addition two digit number in c how to add digit of a given number 4. Program to find the sum of digits of a given number. print out the sum of two digits in c digital sum program in c C programme to find the sum of digits of given number c programme to find the sum of digits program to find sum of digits in c find the sum of digits 3. . Write a c program to print sum of digits.r algorithm 6. Write a c program to print sum of digits. c sum of all digits in a string get the sum of a digits of a number Write a program to print sum of digit and reverse of a given number sum of digits in c using for loop c program to find the sum of digits of a number how to find sum of digits of a number in c Write a program to sum the digits of any given integer number.Input:459Sum:18 Write a program to find the sum of digits of given number. count the digit that reapeats more frequently in an integer in C add a numbers in c sum of digits c Write a program to find out sum of digits of given number. syntax of rounding of floating point number in c 2.Write a C program to enter a 4 digit number and calculate sum of digits C program to calculate the number of permutations of given digits print the sum of digits of a given number in c print the sum of digits of a given number sum of digits of number in c 1. To write a c program to print sum of digits of a given number. how to find sum of individual digits of a number write a program from one number from user and print sum of digit add the digits of a 2 digit number in c write a program that takes an integer number and prints out the sum of the digits sum of different digits in c c program to add 4 digit number arry find number of digits and their sum in c find digits of a number and their sum in c program to add digits of a number Develop a C routine to find sum of digits of given number? WAP to input a five digits number and find the sum of digits number with digits sum as c program to find sum of digits c program to find sum of digits of a 4 digit number Sum of digits for the given number in c program how to find the sum of the digits of a number in c c program to sum of digits sum of digits in c Write a c program to calculate sum of inditiual digits of a positive number digits sum in c write a c program to add digits of a number c program to find sum of digits c program to find sum of digits of a 3 digit number Write a program to find sum of 3 digit number entered by the user. sum of digits in c program how to add digit of a number program for finding the sum of given number with given no of digits addition of digits of a given number in c sum of last x digits in c check if a number is sum of two digits in c c program if a sum is the sum of digits loops sum of digits in integer c with 0 sum of digits in integer c different method to find sum of digits digit sum c sum of all digits of a number in c sum of all digits of an integer C function in C to add digits of an integer program to calculate sum of digits c program sum of digits calculate sum of digits of a number write a program to print the sum of all digits of a given number c sum of digits get digit sum program in c adding digits of a number in c sum of digits in c user defined If a three-digit integer is input through the keyboard, write a program to calculate the sum of its digits. total of all digits and print them in c c program to find the sum of given number sum of digits of a number in c find sum of digits of a number in c how to print sum of no of digits in c wap to print sum of digits
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source