answersLogoWhite

0


Best Answer

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

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

#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 the first digit(left most digit)

b=num%10; //retrieves the fourth digit(right most digit)

sum=a+b;

printf("The sum of first and last digit is %d", sum);

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: If a five digit number is input through the keyboard write a program to calculate the sum of its digits?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is hexadecimal code?

Computer engineers use to use the hexadecimal code to program computers, or the base 16. Hexadecimal numbers use the digits 0 through 9, plus the letters A through F to represent the digits 10 through 15.


How many digits did Fabrice Bellard calculate in 2009?

more that 50 digits.


How many digits in a program element code?

The PEC must be 8 digits ending in a letter.


How many digits are in 1 through 284?

744 digits.


How can you calculate leap year?

divid the last to digits by 4


How many digits of pi did William shanks calculate?

707


How do you make the copyright symbol on the computer?

Press Alt key in the keyboard and press the digits 0,1,6,9


Which brothers built a homemade supercomputer to calculate the digits of Pi?

computer


What is 123767474576 multiplied by 56745674?

You can calculate that on any calculator, and get a result with 10 significant digits or so - more than you need for most practical situations. In Excel, you get 15-16 significant digits. If you really want all the digits, you can:* Use the Wolfram Alpha website. Use "*" for multiplication. * Install a program that can handle more digits. For example, a Python interpreter will work just fine, and you can use it as a calculator.


How many digits would it take to write 1 through 300?

630 digits.


How many arrangements of 3 digits can be formed from the digits 0 through 9?

1000


Who is responsible for finding how many digits are in pi?

Nobody is responsible. Different groups have decided, on their own, to calculate pi to many digits - as a sort of challenge.