answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

void main()

{

int oddSum = 0, evenSum = 0, i = 0;

char n[50] = {0};

clrscr();

printf("Enter the number : ");

scanf("%s", n);

while(n[i] != '\0')

{

if(i % 2 == 0)

oddSum = oddSum + (n[i] - 48);

else

evenSum = evenSum + (n[i] - 48);

++i;

}

printf("Odd sum is %d and even sum is %d\n", oddSum, evenSum);

getch();

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: To find sum of odd position digits and even position digits separately?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

C program to find the sum of odd positioned digits and even positioned digits of a number seperately?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; main() { int n,s,r,t; clrscr(); printf("enter n"); scanf("%d",&amp;n); s=0;t=0; while(n!=0) { r=n%10; { if(r%2!=0) t=t+r; if(r%2==0) s=s+r; } n=n/10; } printf("sum of even position digits%d\n",s); printf("sum of odd position digits%d\n",t); getch(); }


How do you find the last 2 digits of the question 14x13x12x11x10x9x8x7x6x5x4x3x2x1 quickly?

Since there are two multiples of 5, and plenty of even numbers, the last two digits are 00.


Which is greater of two positive numbers?

It's the number that has more digits to the left of the decimal point (if there is no decimal point, it's the number with more digits). If the number of digits to the left of the decimal point is the same, find the position farthest to the left where the digits are different. The number with the greater of those two digits is the greater number. For example, 10000 is greater than 9999 because 10000 has more digits, and 6350 is greater than 6349 because the farthest-left position that is different is the tens place, and 5 is greater than 4.


How do you find the sum of digits of each number?

Add the digits together. The sum of the digits of 23 is 5.


Shell program to find the sum of cube of individual digits of a number?

Shell problems are programs that can be run to find out information about numbers. The problem can help find an even or odd number, or what the sum of a cube is.


What does find the sum of the digits of each number above mean?

Add the digits together. The sum of the digits of 23 is 5.


What happens to the median when you come up with two answer?

when you have an even amount of numbers while trying to find the median, you first find the two numbers that are at the median and then take all the numbers between them and find the median of that. if that amount of digits is also even, then you must have a decimal median.


What is the largest three-digit even number that uses the digits 3 4 and 5?

To find the largest three-digit even number using the digits 3, 4, and 5, you need to arrange these digits in descending order to maximize the number, ensuring that the last digit is even. The largest possible even number is 542


How can I make a quick and easy family dinner?

Find a day and make up a bunch of dinners that your family enjoys, and freeze them (You could even freeze the different courses separately so that you can


Is 0.402 bigger than 0.428?

No. Compare equivalent digits one by one, from left to right, until you find a digit where there is a difference. In this case, the number with the bigger digit in that position is also the bigger number.


Do umbrellas always come with the outdoor tables?

If you look around for different brands you will be able to find sets that come with both the table and the umbrella. Usually, they will sell them separately but if you search at warehouses like Costco or BJ's, they will often have them in sets or even if they sell them separately they will be a little cheaper than other retail stores.


Where would you look to find the position of a place?

where can i find the position of a place