The following function will sum the digits in any positive number.
unsigned int sum_digits(unsigned int num, unsigned int base=10)
{
sum=0;
if(base>1) // base must be 2 or higher
{
while(num)
{
sum+=num%base; // add least significant digit to sum
num/=base; // shift right by base
}
}
return(sum);
}
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
5
program to extract a given word from a file
write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)
see pages 43-49 in Principles of Program design by M. A. Jackson, 1975
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
You write the number and then follow it with the digits in reverse order.
5
All four of the digits given are significant digits.
Yes, do write, or if you're too lazy to your homework, use google.
THIS IS ONLY FOR UPTO A FIVE DIGIT NO. BY ROHAN ARORA#include#includevoid main(){int a,n,s,sum=0;clrscr();printf("Enter the number between 1 to 5 digits\n");scanf("%d",&a);while(a!=0){n=a%10;sum=sum+n;a=a/10;}printf("The sum of digits of the given numberis %d",sum);getch();}
8086 assembly language program to check wether given number is perfect or not
36
Million is the name given to a number with 7 digits in front of the decimal place. In order to write out any number take the number you are given and and move the decimal place to the right until you have 7 digits in front of the decimal. add zeros to the end until it has 7 digits in front of the decimal place. So 2.25 million would be 2,250,000.
03458
The number is 36.
program to extract a given word from a file