answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

main()

{

int n,s,r,t;

clrscr();

printf("enter n");

scanf("%d",&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();

}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to find the sum of odd positioned digits and even positioned digits of a number seperately?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.


Write a program in java to enter 3 digits or more arrange the digits of the entered number in ascending order and display the result?

public static void main(String[] args) { int val = 100; int val1 = 50; System.out.println("Number of digits in " + val + " is: " + new String(val + "").length()); System.out.println("Number of digits in " + val1 + " is: " + new String(val1 + "").length()); }


How do you write a Java program to accept a 3-digits integer number and print out the highest digit from the derived input?

The tricky part is getting the individual digits. There are basically two ways to do this: 1) Convert the number to a string, and use string manipulation to get the individual digits. 2) Repeatedly divide the number by 10. The digit is the remainder (use the "%" operator). To actually get the highest digit, initially assume that the highest digit is zero (store this to a variable, called "maxDigit" or something similar). If you find a higher digit, replace maxDigit by that.


How a check digit is calculated?

Check digits are determined (or derived) by a set algorithm using the digits of the account number.


What is radix in number system?

The radix refers to the base of a number system: the total number of possible digits. The decimal number system that we all use is base ten, as it has ten distinct digits (0,1,2,3,4,5,6,7,8,9). Commonly used bases in computing include binary, octal, and hexadecimal, which have two, eight, and sixteen digits, respectively.

Related questions

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

no thanks


How do you make a program that counts how many times each digit occured in the integer?

To count the number of times a digit occurs in an integer, start by initializing an array of ten counts of digits, such as int digits[10];Then, in a loop while the number is non zero, increment the element in the digits array that corresponds to the units digit, and then divide the number by ten, such as digits[number%10]++ and number/=10;int digits[10];int i;int number = some number;for (i=0; i


Write a program to find the number of digits in the number?

#include &lt;stdio.h&gt; int main(int argc, char **argv) { if (argc&lt;1) { printf("Usage: %s number\n",argv[0]); return -1; } int digits=1, i=atoi(argv[1]); while (i/=10) ++digits; printf("%d\n",digits); }


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

There are many shell programs that will find the sum of the square of individual digits of a number. A small example is: SD=3n=2, sum=2, and SD=2.


How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.


What number has thirteen digits?

The number 1,234,567,890,123 has thirteen digits.


What does a Merchant Number look like?

A Merchant Number is usually between 6 and 15 digits long. Examples: Natwest Streamline Merchant Number = 8 digits HSBC Merchant Number = 8 digits Lloyds TSB Cardnet Merchant Number = 15 digits Bank of Scotland Merchant Number = 15 digits Barclays Merchant Services Merchant Number = 7 digits American Express Merchant Number = 10 digits Diners Club Merchant Number = 10 digits JCB (Japan Credit Bureau) Merchant Number = 13 digits Elavon Merchant Number = 10 digits AIB (Allied Irish Bank) Merchant Number = 11 digits Ulster Bank (For Ireland Vendors only) Merchant Number = 8 digits Chase Payment Tech Merchant Number = 6 digits


Which is greater the greatest whole number with 5 digits or the least whole number with 6 digits?

The least whole number with 6 digits is greater because it has more digits than 5 digits.


What is the largest digits number with repeated digits?

The largest ten digit number with no repeated digits is '9876543210'.


Is the number with the most digits always greatest?

no, it matters with the number not digits


Which is greater the greatest whole hnumber with 5 digits or the whole number wit 6 digits?

which is greater, whole number with 5 digits or the whole number with 6 digits?


How may digits are there in a number?

Digits is how many numbers you have in a number. If you have the number 4 it has one digit if you have the number 20 it has two digits and if you have the number 558 it has three digits. So basically in the number 1085 it has 4 digits because there is 4 numbers in it, the numbers are 1,0,8 and 5. Hoped you understand.