Search
 
SCRIPT & CODE EXAMPLE
 

C

c Program for Sum of the digits of a given number

// C program to compute sum of digits in
// number.
#include <stdio.h>
 
/* Function to get sum of digits */
int getSum(int n)
{
    int sum = 0;
    while (n != 0) {
        sum = sum + n % 10;
        n = n / 10;
    }
    return sum;
}
 
// Driver code
int main()
{
    int n = 687;
    printf(" %d ", getSum(n));
    return 0;
}
Comment

digit sum number in c

#include <stdio.h>

int main() {
    int number;
    int sum=0,reminder;
    printf("enter the number:");
    scanf("%d",&number);
    while (number>0){
        rem=number%10;
        sum=sum+rem;
        number = number/10;
    }
    printf("%d",sum);
}
Comment

sum number in c

#include<stdio.h>
int main()
{
	int a,b;
    printf("enter numbers:");
    scanf("%d %d",&a,&b);
    printf("sum is:%d",(a+b));
}
Comment

the sum for numbers in c

#include <stdio.h>

void main (){

int i = 0  , s  =0 ;
while (i<=10){
s  = s + i ;
i++ ;
}
}
Comment

how to count digits and sum of digits in C

Enter the number
300
Given number = 300
Sum of the digits 300 = 3
 
 
Enter the number
16789
Given number = 16789
Sum of the digits 16789 = 31
Comment

PREVIOUS NEXT
Code Example
C :: pass the pointer to the function 
C :: silicon valley 
C :: A binary tree whose every node has either zero or two children is called 
C :: how to print a file c 
C :: servo motor arduino 
C :: c fractional sleep 
C :: c/c++ type format 
C :: how to create calculator with switch in c 
C :: ROUNDING decimal number in C 
C :: multiplicationin c 
C :: c print char 
C :: install gnome tweaks ubuntu 20.04 
C :: c strcat 
C :: callback c++ c 
C :: c convert char to int 
C :: c programming how to force stop the programme 
C :: arduino sketch structure 
C :: print variable adress c 
C :: volatile keyword in c 
C :: doble puntero en c 
C :: c exit 
C :: mongo script to find collection size in database 
C :: c language float user input 
C :: how to change file permissions in C language 
C :: arduino empty serial buffer 
C :: gitlab ci heroku 
C :: scopes in c 
C :: increment pointer value in c 
C :: c code recursive function to print numbers between two numbers 
C :: c program for calculating product of array 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =