answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

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

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: 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?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How many digits did Fabrice Bellard calculate in 2009?

more that 50 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


How many sequences of 6 digits can you form given the condition that no two adjacent digits have the same parity?

2 x 56.


What is a spook number-?

8161 is a Spook Number. It is made up of digits that are not 0s. All the digits separately add up to give double the first digit. 8+1+6+1=16 2x8=16


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.


How many digits in pi can computers now calculate?

5,983,948,393,122,123,098 nahson.com for more information


What is the the square root of 5?

The square root of 5 is approximately 2.236. It is an irrational number meaning we can not calculate its value no matter how many digits we can find. At one point a NASA computer was used to calculate the first million digits of the number.


How to calculate the value of pi from the infinite series?

There are several infinite series. To find PI to x digits, evaluate each term to x+2 digits until the value is 0. Then round to x digits.


Can significant digits be written in a fraction form?

The significant digits of a number represent a count of digits and so are represented by an integer. Any integer can be written in fractional form.