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

Would you like to merge this question into it?

#### already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

#### exists and is an alternate of .

If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example if the number that is input is 12391 then the output should be displayed as 23402.
//Author::Mudasir Yaqoob.....

#include<stdio.h>
#include<conio.h>

int main()
{

long number,t;
int i=0;
long temp[5];
printf("Enter the five digit number:\n\n");
scanf("%ld",&number);
while(i<=4)
{

t=number%10+1;
temp[i]=t;
number=number/10;
i++;

}
printf("Reverse number\n\n\n\n");
for(i=4;i>=0;i--)
{
printf("%ld",temp[i]);
}
getch();
}
2 people found this useful

# Write a program that would input a 4 digit number and computes the sum of the digit?

\nIn Visual Basic....\n. \nDeclare a variable called "InputNumb"\n. \n-->> Do some checking using the len function to ensure that it has four digits\n. \nDeclare a variable

# If a 4 digit number is input through keyboard Wap to obtain a sum of the first and last digit their number?

include #include void main() { int

# How do you write a program in assembly language to calculate the sum of two single digit numbers?

;this program adds 2 1-digit numbers ;without carry ,sum < 10 or with carry , sum >9 ;coded by -----LenmorVash------ ;coded in emu8086 org 100h mov dx,offset str mov ah

# Write a program in c to calculate the sum of first and last digit of a five digit no?

// Returns the sum of the left-most and right-most digits of num. // If num contains only one digit, returns num. unsigned int getSum(const unsigned int num) { // Specia

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

include #include using std::cin; using std::cout; using std::endl; using std::string int main() { const int numberOfdigits = 6; string myNumber = "0"; char myNumberChar[n

# Five digit number input the keyboard program reverse the number?

include #include using std::cin; using std::cout; using std::endl; using std::string; int main() { const int numberOfDig = 5; string num = "0"; cout num; string revNum =

# What is the Programme to calculate the sum of a five digit number?

include #include void main() { long n,s=0,t,d; clrscr(); cout > n; t=n; while(n>0) { d=n%10; s=s+d; n=n/10; } cout

# 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)

# Write a c program to find the sum of the digits of a number?

include int sumOfDigit(int x){ int ans = 0; while(x>0){ ans += (x%10); x /= 10; } return ans; } int main(void){ printf("%d",sumOfDigit(12)); retu

# Write a program to print sum of the digits in the given number?

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

# 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 di

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

# 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

# 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

# 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

# Write a c program to find the sum of the five digits of a number?

To determine the value of the least-significant digit in a number,you divide by the base and take the remainder. To get the nextdigit, divide by the base and repeat. The follo