Generation

generate functionThu, 06 Apr 2023

NuIT corporation has decided to send their three-digit acknowledgement number to the customers in a different way. Instead of directly sending three-digit acknowledgement number, it is sent as two numbers. First number is the sum of odd digits and the second number is the sum of even digits. Odd digits sum and even digits sum is calculated based on the digits of the given number. Write a program to implement sum of odd digits and sum of even digits.

#include <stdio.h> int main() { int n,rem,odd=0,even=0,sum=0; scanf("%d",&n); while(n!=0) { rem=n%10; sum=sum+rem; n=n/10; if(rem%2==0) { even=even+rem; } else { odd=odd+rem; } } printf("%d %d",odd,even); return 0; }

Want to kickstart your project?Use the new AI Studio to create your code