sum of individual digits in c using function

Solutions on MaxInterview for sum of individual digits in c using function by the best coders in the world

showing results for - "sum of individual digits in c using function"
Lucie
21 Sep 2016
1//program to find the sum of digits:
2
3#include<stdio.h>
4int main()
5{
6  int num,sum=0,r,temp;
7  printf("Enter the number:\n ");  //taking input from the user
8  scanf("%d",&num);
9  
10  temp=num;           //assigning num to temporary variable
11  
12  while(temp!=0)
13  {
14    r=temp%10;
15    sum=sum+r;
16    temp=temp/10;
17  }
18  printf("\nGiven number = %d",num);
19  printf("\nSum of the digits = %d",sum);
20}
21
22//code By dungriyal
Alessia
13 Aug 2018
1#include <stdio.h>
2int main()
3{
4   int n, sum = 0, r;
5
6   printf("Enter a number\n");
7
8   for (scanf("%d", &n); n != 0; n = n/10) {
9      r = n % 10;
10      sum = sum + r;
11   }
12
13   printf("Sum of digits of a number = %d\n", sum);
14
15   return 0;
16}
Elías
13 Nov 2018
1#include <stdio.h>
2
3int individualSum(num);
4
5void main ()
6{
7    int num, ret;
8
9    ret = individualSum(num);
10    printf("\nThe sum of individual digit is %d\n", ret);
11}
12
13int individualSum(num)
14{
15    int i, rem, sum = 0;
16    printf("Enter the number: ");
17    scanf("%d",&num);
18
19    while(num!=0)
20    {
21        rem = num % 10;
22        num = num /10;
23        sum = sum + rem;
24    }
25  	
26  return sum;
27}
28
Valentina
11 Apr 2018
1Enter the number
2300
3Given number = 300
4Sum of the digits 300 = 3
5 
6 
7Enter the number
816789
9Given number = 16789
10Sum of the digits 16789 = 31
queries leading to this page
write a program to calculate sum of digits of a number in cc program to calculate the number of permutations of given digitswrite a program to print sum of digit and reverse of a given numberfunction to count number of digits in cwrite a c program to calculate sum of digits of any number digital sum program in cthe best way to add a number to a number in cfind number of digits and their sum in ccount of digits in cprogram for finding the sum of given number with given no of digitsc programming add 0 number digitssum of digits in integer c with 0c add digit to integerprogram that compute the value of the sum of the digits in an integer in cprogram for sum of the digits of a given number csum of numbers using cc program to count number of digits in an integerhow to add numbers in cc given length and sum of digitsc program for sum of digitsc program to find sum of even digits in a given numberwrite a program to find sum of 3 digit number entered by the user count sum of digits in cwrite a program to find the sum of all the digits of a number in csum of digits up to single digit in cprogram to find sum of digits3 write a c program to print sum of digits r algorithmsum of integers in cprogram to calculate sum of digits1 to write a c program to print sum of digits of a given number program to add digits of a numberwrite a program to find the sum of all the digits of a number by taking n input in cc code how to calculate the sum of the first three digits of a number using loopc program to find the sum of all the digits14 09write a c program to calculate sum of digits of a numberc program to compute the sum of digits in a given integerwrite a program from one number from user and print sum of digitsum of digits in c using for loopsum of all the digits of a nuymber program in cc add digits instead of numbersc program to add 4 digit numberhow to take in an input of integers and sum all of the digits in chow to find the sum of the digits of a number in cc program to find total digits in a numberadd digit of a number in cfind out integer of sum of digit in cc program sum of digitssum of all numbers in a given range in cfinding sum of digits in csum of digits in integer csum of individual integers in csum of numbers in string in csum of n numbers in c using for loopprogram to find sum of digits in chow to add numbers in c languagesum of digits in c user definedwap to print sum of digitsprint number and add this number in c langauge a c program to count number of digits in a numberhow to sum digits of a number in cc program if a sum is the sum of digits loopshow to print sum of no of digits in cc sum of digitssum of odd digits of a number in cc program to find sum of digits of a 5 digit numberhow to find sum of individual digits of a numberadd sum of digits in ccode to calculate sum of digits c4 program to find the sum of digits of a given number sum of all digits of an integer c6 write a c program to print sum of digits get the sum of a digits of a numbercode to calculate sum of digits in c using functionsdevelop a c routine to find sum of digits of given number 3fhow to add digit of a given numberformula to find number of digits in a number in cprinting sum of digits in csum digits of a number chow many number for the sum on n numbers in cdigit sum in c count the numer of digits in a int cadd numbers ccount number of digits in a number in cc program to find sum of digits of a 3 digit numberc sum of all digits in numberwrite a program to find the sum of digits of given number count the number of digits in cc programme to find the sum of digits of given numberhow to find sum of digits of a number in ccount the digits of a number in cadd the digits of a 2 digit number in chow to add digit of a numberaddition of digits of a given number in cprint sum of digits in cdigit sum chow to get digits of of a number in c with loopsum of digit number in csum of different digits in cc given length and sum of digits find sum of digits of a number in cc program to calculate sum of digits of a number sum of 5 digits in cadding the digits of a number in cwrite a c program to find sum of individual digitsadd digits of intiget clet total number 3d 5 total number 3d number in csum of numbers between range in cwrite a c program to calculate sum of digits of a number sum of number in cc program to calculate sum of digits of a numberfind digits of a number and their sum in cadding digits of a number in cc program to keep adding their digits till one digitprogram to sum of digits of a number in c in basesum of digits until single digit in chow to count the number of digits in an integer in c langnumber with digits sum as ccount the digit that reapeats more frequently in an integer in ccount digits in a number in csum of digits for the given number in c programc program to find the sum of digits of a numbersum of digits in c algorithmc program to count number of digits in given numberc function to sum symetric digitsc program to find the sum of given numberwrite a c program to print sum of digitsc program to find sum of digits of a numberto add even digits from the given number c programadd digits together csum of digits c programc programme to find the sum of digitssum of last x digits in cdigits sum in csum of 4 digit number in csum of individual digits in cc sum to single digithow to get the sum of digits in cadd digits of a number in ctotal of all digits and print them in cwrite a program to find out sum of digits of given number count no of digits in csum of numbers in cfind digit sum of a number in chow to count number of digits in a number in cwriite a c program yo count total number of digits of an intiger numberfind the sum of digitsadd all the digits together ccheck if a number is sum of two digits in chow to sum all digits in a number in cc program find sum of digitsc program to find sum of digitssumming up the digits in chow to retrieve sum of digits 5cof number in cwrite a c program to count number of digits in any number sum of even digits in chow to add numbers using for loop in csum of digits using function in ccode to calculate sum of digits c algorithmhow many digit need for sum in c c program to count total number of digits of an integersum of digits in c languagesum of natural numbers in csum of the digits of a number in cc program to find sum of digits of a 4 digit numbersum of digits in ccalculate sum of all digits of number in cdifferent method to find sum of digitsc program to add 4 digit number arrya digits sum solution in cprogram to find sum of even numbers in digit in cthe sum of digits of number in caddition two digit number in cwap to input a five digits number and find the sum of digitsadd a numbers in cwrite a c program to add digits of a numberhow to get the digits of an integer and sum the odd in csum of all digits of number in ccalculate sum of all numbers present in a string in csum of two large numbers represented as strings csum of the even digits of a number program in csum numbers in cc program for adding digits of a numberwrite a c program to find the sum of individual digits of a given number sum of digits of a five digit number in cadd numbers in cwrite a c program to calculate sum of digits of a numberc program to find the sum of digits of a given numberfind sum of all the digits in cc program to count number of digits in a numberprint the sum of digits of a given number in csum of digits that equal a number entered by the user in csum of digits of a number in cwrite a c program to calculate sum of inditiual digits of a positive numberhow to get the sum of digits of a number in csum of second digits of number in cif a three digit integer is input through the keyboard 2c write a program to calculate the sum of its digits write a program to take a number and calculate the sum of digit of a number in cprint sum of natural numbers in csum of digits of number in csum of all digits of a number in cprogram to sum of digits of a number in chow to count the digits in an int cc given length and sum of digits 2 write a c program to enter a 4 digit number and calculate sum of digitshow to count number of digits in cwrite a program to find the sum of all the digits of a number in csum of numbers using function in ccount the number of digits in a number in c programcalculate sum of digits of a numberhow to find the sum of the digits in csum of the digit in csum of its digits in cc program to find the sum of digits for the given numberc program calculate sum of digits of numbersum of digit in c how to add numbers in an integer in cget digit sum program in cdigits sumin cchar value in sum with int csum digits of a number in chow add the number of digits in cc program to get the sum of digits that get the value entered by the userwrite a program to print the sum of all digits of a given numbersum of digits problem solution in csum of digits of 5 digit number in csyntax of rounding of floating point number in csum of n numbers in cwrite a c program to find sum of individual digits using forhow to add digits in a number in cwrite a program in c to display sum of all digits of any given number add 1 to individual digit of a number in csum of digits of a five digit number c programprint the sum of digits of a given numberwrite a program that takes an integer number and prints out the sum of the digitscount number of digits using loop in cwrite a c program to print sum of digits c programming using digit summationsum of numbers in a digit chow to print directly sum of digits in cc program to find sum of individual digits of a given numberhow many number need for the sum of any number numbers in csum of individual digits in c using functionfind the sum of digits in c programc program to calculate the sum of digits of a numbercount the number of digits in a number in csum of digits of the number in csum of digits in c programfunction in c to add digits of an integerwrite a program to sum the digits of any given integer number input 3a459sum 3a18program to calculate sum of digits of a number in cfind the sum of individual digit of a number in csingle digit sum in cto find the sum of digits of a number in cwrite a program to input a number and find out the sum of its digits in cwrite a program in c to calculate sum of all digits present in a user given number to count number of digits in a number in cprint digit sum in cadd the digits of a number in cc sum of all digits in a stringprogram to count number of digits in csum of digits cprogram to find sum of digits of a number in csum of digits of a number in c using for loopprint out the sum of two digits in csum of even digits in a number in cc program to sum of digitssum of individual digits in c using function