#include <stdio.h>
void main()
{
int digi,num,i,sum=0;
printf("Enter the number of digits:");
scanf("%d",&num);
while(i>0);
{
for(i=0;i<10000;i++)
{
digi=num;
i=digi%10;
sum=sum+i;
num=digi/10;
}
printf("The sum of digits entered is %d",sum);
}
}
write an assembly language program to find sum of N numbers
no thanks
There are many shell programs that will find the sum of the square of individual digits of a number. A small example is: SD=3n=2, sum=2, and SD=2.
Add the digits together. The sum of the digits of 23 is 5.
Shell problems are programs that can be run to find out information about numbers. The problem can help find an even or odd number, or what the sum of a cube is.
Add the digits together. The sum of the digits of 23 is 5.
class Sum_Of_Digits { public static void printSumandnoofdigits(int n) { int temp = n; int count = 0; int sum = 0; while ( n > 0 ) { sum = sum + n % 10; n = n / 10; count ++; } System.out.println("The number is..." + temp ); System.out.println("The sum of digits is..." + sum); System.out.println("The number of digits is..." + count); } }
Here You go........... # include<stdio.h> # include<conio.h> void main() { int no,sum=0,rem=0; clrscr(); printf("\nEnter a Number: "); scanf("%d",&no); while(no>0) { rem=no%10; sum=sum+rem; no=no/10; } printf("\nSum of digits of a number: %d",sum); getch(); }
5050, according to the program I quickly whipped up.
In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT "Enter a number: "; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT "The sum of the digits is "; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.
The sum of the digits is 6.
enter the number whose digits are to be added num is the given value num=0! k=num%10 sum=sum=k k=num/10 num=k print the sum of the digits