Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

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
Shell :: edit a file linux 
Shell :: curl save file 
Shell :: raspberry pi mongodb server 5.0 
Shell :: linux date format utc 
Shell :: checkout remote git branch 
Shell :: how to connect your repo to your vscode 
Shell :: upload directory ssh to remote 
Shell :: installing parse-dashboard with npm 
Shell :: webpack/config/html 
Shell :: linux set environment variable 
Shell :: git set upstream always 
Shell :: compile electron app 
Shell :: powershell or command prompt 
Shell :: bash tokenize string 
Shell :: git merge dev to local branch 
Shell :: speed up ffmpeg video 
Shell :: git check differences between two projects 
Shell :: kubernetes copy secret form another namespace 
Shell :: mkdir -p vs mkdir 
Shell :: git squase to rename author 
Shell :: how to rebase initial commit 
Shell :: linux switch user 
Shell :: remove write proteced in usb ubuntu 
Shell :: vscode publish to github organisation 
Shell :: ionic capacitor run ios 
Shell :: make zip file command 
Shell :: awk if 
Shell :: powershell global variable 
Shell :: chmod chown 
Shell :: how to deploy react and backend to github pages 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =