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

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();
}
+ 4 others found this useful
Thanks for the feedback!
Follow

Most of your major acting roles have been in dramas. Is that a coincidence, or is there a reason you're attracted to that specific genre?

View Full Interview

How do you calculate the sum of all three-digit positive numbers?

The highest 3-digit number is 999. It's the 999th counting number.    The first 99 counting numbers have fewer than 3 digits.    So there are (999 - 99) = 900 positi (MORE)

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

include<stdio.h> 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",& (MORE)

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<stdio.h>#include<conio.h>void main(void){int num, a, b, sum;printf(""Please enter a four digit number: "");scanf("%d", &num);a=num/1000; // retrives th (MORE)

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 <stdio.h> int digit_sum(int); int digit_sum_rec(int); main() { int num; printf("Enter 5 digit positive integer. : "); scanf("%d",&num); printf("The s (MORE)

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 last (MORE)

Setting Number Formats in Excel

A spreadsheet in Excel is comprised of a grid of cells. Each cell (which is defined as the intersection between a row and a column) can be allocated its own attributes. This i (MORE)

Counting: Activities and Number Crafts for Preschoolers

Your preschool-aged child is at a point in his or her young life when learning is incredibly fun and entertaining. Even though attention spans are very short, their ability to (MORE)
In Bible

Introduction to the Book of Numbers

The book of Numbers is the fourth book in the Bible. It chronicles the history of the Hebrew people, following the giving of the Ten Commandments to Moses at Mount Sinai. It i (MORE)
In Bible

The Book of Numbers

The Bible tells us that the Exodus of Israelites out of Egypt was one of the greatest epic adventures in history. Against impossible odds, but with the help of God, Hebrew peo (MORE)

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

include<stdio.h>   void main()   {   int no,rem=0,sum=0,n; /*declaration*/   printf("Enter 2 digit number:");   scanf("%d",&no);   for(n=1;n<3;n (MORE)

C program to find the sum of the digits of a number?

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) (MORE)

Write a program to find the sum of the digits and reverse of the digits using inheritance?

There is a far easier way to implement the required functionality than using inheritance. However, to answer the question, here's one possible solution that makes use of inher (MORE)