What would you like to do?

# If a five digit number is input through the keyboard write a program to calculate the sum of its digits?

# If a 4 digit number is input through the keyboard write a C program to obtain the sum of first and last digit of this number?

include #include void main(void) { int num, a, b, sum; printf(""Please enter a four digit number: ""); scanf("%d", &num); a=num/1000; // retrives the first digit(left most dig…it) b=num%10; //retrieves the fourth digit(right most digit) sum=a+b; printf("The sum of first and last digit is %d", sum); }

# What to do to write a c program to input a number then a digit and findout the place value of that digit?

include int main() { int d,j=1,i,flag=0,count=0,k=0; int b[]; char a[],c; printf("enter the number="); scanf("%s",a); printf("enter the digit="); scanf("%c",&c); prin…tf("the place value of given digit is:"); for(i=0;a[i]!='\\0';i++) { if(a[i]c) { b[k]a[i]-'0'; b[k]=b[k]=*j; flag=1; count++; k++; } j=j*10; } if(flag==1) { printf("the place value of given digit %c is:",c); for(i=0;i

# A 5 digit positive integer is entered through the keyboard how to write a function in C to calculate sum of digits of the 5 digits number by using recursion and without using recursion?

include int digit_sum(int); int digit_sum_rec(int); main() { int num; printf("Enter 5 digit positive integer. : "); scanf("%d",&num); printf("The sum of the d…igits is: %d\\n",digit_sum(num)); printf("The sum of the digits is (calculated recursively): %d\\n", digit_sum_rec(num)); } int digit_sum(int n) { int t=0; while(n) { t+=n%10; n/=10; } return t; } int digit_sum_rec(int n) { if(n==0) return 0; return (n%10)+digit_sum_rec(n/10); }

# Write program for sum of first and last digit of a number?

// this v'll work to obtain sum of 1st and last number of any number #include int main() { int num,sum=0,i,fd,ld; printf("enter the number); scanf("%d",&num); ld=n…%10; //will get the last digit while(num!=0) { fd=n; n/10; //to get the 1st digit } sum=fd+ld; //add 1st n last digit printf("\\n sum of 1st n last digit is %d",sum) }

# Write a program in c language to reverse the five digits number?

//Reverse of the Number // Programme Written By Maulin Thaker Ahmedabad; #include #include void main() { int a,b,c,d,e; clrscr(); printf("Enter the Number to Find it's Revers…e\\n"); scanf("%d",&a); while(a!=0) { b=a%10; c=a/10; printf("%d",b); a=c; } getch(); }

# Write a c program to compute the sum of digits of a given integer number?

int sumDigits(int n) { int sum = 0; while( n > 0 ) { sum += (n % 10); // add last digit of n to sum n /= 10; // divide n by 10 to "chop off" the la…st digit } return sum; } ____________________________________________________ C program to find the sum of entered digit: By Jatinder Pal Singh #include #include void main() { clrscr(); int n,num,x,sum=0; printf("Enter a number="); scanf("%d",&n); while(n>0) { x=n%10; sum=sum+x; n=n/10; } printf("Sum of digits of a number=%d",sum); getch(); }

# Write a C program for sum of two digit numbers by using loop?

include void main() { int no,rem=0,sum=0,n; /*declaration*/ printf("Enter 2 digit number:"); scanf("%d",&no); for(n=1;n…

# If a five digit number is input through the keyboard write a program to reverse a number?

include #include { unsigned long reverse(int); int n; clrscr(); Printf("reverse of a given no is:%lu",reverse(n)); getch(); } unsigned long rev(int x); {… unsigned long r=0; while(x>0) { r=r*10+(x/10); x=x/10; } return r; }

# Write a program to compute sum of digits of a given number in Java?

public static final int getSumDigits(int n) { int sum = 0; while( n != 0 ) { // Add right most digit to sum sum += n % 10; // Chop off right most digit from n n… /= 10; } return sum; }

# Write a program that would find the count of occurrence of largest digit in the input number?

include #include void main() { long int n,r,m,max=0,count=0; clrscr(); printf("Enter the Number:"); scanf("%ld",&n); m=n; … while(n>0) { r=n%10; if(r>max) max=r; n=n/10; } printf("\\nLargest Digit is = %ld",max); while(m>0) { r=m%10; if(r==max) count++; m=m/10; } printf("\\n\\nOccurence of Largest Digit %ld is = %ld",max,count); getch(); } output: Enter the Number:68596999 Largest Digit is = 9 Occurence of Largest Digit 9 is = 4

Answered

# A five digit no is entered through the keyboard write a program to obtain the reversed no and to determine whether the original no and reversed no is equal or not?

1) first you have to find the reverse of an integer.. code is given below, #include void main() { int a,b,m,s=0; printf("enter the value of a"); scanf("%d",&a); b=a; …while(a!= 0) { m=a%10; s=s*10+m; a=a/10; } if(s == b) { printf("original number is equal to the reversed number"); } else { printf("original number is not equal to the reversed number");

Answered

In Technology

# How do write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average?

include #include void main() { float arr1[5], avg=0, sum=0; cout…

Answered

# Write a java program to find out the sum of a number of n digits?

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); } }

Answered

In Technology

# Using if condition and while loop in C get a number of input from the keyboard and calculate the sum of odd and even digits separately?

include #include void main() { int num,num_save; int ar[5],i=0,res_e=0,res_o=0; printf("\\nEnter the number : "); scanf("%d",&num); num_save=num; while(num_s…ave>0) { ar[i]=num_save%10; num_save/=10; i++; } i--; while(i>=0) { if(ar[i]%2==0) res_e=res_e+ar[i]; else res_o=res_o+ar[i]; } printf("\\nNumber is %d\\n",num); printf("\\nSum of even digits is %d",sum_e); printf("\\nSum of odd digits is %d",sum_o); getch(); }

Answered Most Recently

In Technology

# How do you write a visual basic program to sum the odd number digits of a 12 digit code using division and Mod and while loops?

Function sum_odd_digits(ByVal number As Integer) As Integer Dim digit As Integer sum_odd_digits = 0 While number 0 digit = number Mod 10 If digi…t And 1 Then sum_odd_digits = sum_odd_digits + digit number = number / 10 End While End Function