answersLogoWhite

0

#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

12y ago

What else can I help you with?

Continue Learning about Engineering

How write a program to input any number and display digits which are absent in given number?

To write a program that inputs a number and displays the digits absent in it, you can follow these steps: Convert the input number into a set of its digits. Create a set of all possible digits (0-9). Subtract the set of digits from the complete set to find the missing ones. Display the missing digits. Here’s a simple example in Python: number = input(&quot;Enter a number: &quot;) present_digits = set(number) all_digits = set('0123456789') missing_digits = all_digits - present_digits print(&quot;Missing digits:&quot;, ''.join(missing_digits))


How do you write a program in qbasic to input 64751315 to sum?

In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT &quot;Enter a number: &quot;; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT &quot;The sum of the digits is &quot;; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.


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.

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 Armstrong number in visual basic 10?

An Armstrong number (or narcissistic number) for a given number of digits is a number that is equal to the sum of its own digits raised to the power of the number of digits. Here’s a simple Visual Basic 10 program that checks for Armstrong numbers: Module ArmstrongNumber Sub Main() Dim num As Integer Dim sum As Integer = 0 Console.Write(&quot;Enter a number: &quot;) num = Convert.ToInt32(Console.ReadLine()) Dim temp As Integer = num Dim digits As Integer = num.ToString().Length While temp &gt; 0 Dim digit As Integer = temp Mod 10 sum += Math.Pow(digit, digits) temp \= 10 End While If sum = num Then Console.WriteLine(num &amp; &quot; is an Armstrong number.&quot;) Else Console.WriteLine(num &amp; &quot; is not an Armstrong number.&quot;) End If End Sub End Module This program takes a number as input, calculates the sum of its digits raised to the power of the number of digits, and checks if the sum equals the original number.


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.


How do you multiply numbers while considering significant digits?

When multiplying numbers with significant digits, count the total number of significant digits in each number being multiplied. The result should have the same number of significant digits as the number with the fewest significant digits. Round the final answer to that number of significant 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