This is a C program to Increase 1 to all of the given Integer Digit.
This program increases 1 to all of the given integer digit and print the sum of all digits.
1. Take a integer as input.
2. Obtain its remainder and quotient.
3. Increment the remainder by 1 and add to the another variable.
4. Repeat the steps 2 & 3 with the quotient obtained until the quotient becomes zero.
Here is source code of the C Program to Increase 1 to all of the given Integer Digit and print the sum of all digits. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to Increase 1 to all of the given Integer Digit
int number, sum = 0, remainder, count;
printf("Enter a number: ");
remainder = number % 10;
sum = sum + (remainder + 1);
number /= 10;
printf("increasing 1 to all digits: %d", sum);
1. Initialize variable sum to zero.
2. Take a number as input and store it in the variable number.
3. Obtain the remainder and quotient of the variable number. Store the remainder in the variable remainder and override the variable number by quotient.
4. Increment the variable remainder by 1 and add it to the variable sum.
5. Repeat the step 3 & 4 with the quotient obtained until it becomes zero.
6. When it becomes zero, print the variable sum as output and exit.
Enter a number: 3456 increasing 1 to all digits: 22
Sanfoundry Global Education & Learning Series – 1000 C Programs.