Write a program to input a
number and print the sum of even
digits of that number
Answers
Answered by
1
ANSWER: Let N be the input number.
Initialize sum = 0.
Repeat the following steps while N > 0
Set r = N % 10. Store the rightmost digit of N in r.
Set N = N / 10. Remove the rightmost digit of N.
If r is even, set sum = sum + r. If r is odd, do nothing.
The sum of even digits of N is stored in sum.
Answered by
5
Answer:
The program output is also shown below.
int i, num, odd_sum = 0, even_sum = 0;
printf("Enter the value of num\n");
scanf("%d", &num);
for (i = 1; i <= num; i++)
if (i % 2 == 0)
even_sum = even_sum + i;
odd_sum = odd_sum + i;
printf("Sum of all odd numbers = %d\n", odd_sum);
Explanation:
you ca look it form format given please make me as brainiest
Similar questions