Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 17-11-2009
Member
 
Join Date: Nov 2009
Posts: 1
How can i count numbers on odd/even places?

Hello Everyone!
I want to count the sum of digits in odd places and in even places , and after that their difference
we know that first digit it's from the right side

How can I do it with switch?
For example :

A number 23543 :

sum of digits in even places:7 (3+4=7 even places)
sum of digits in odd places:10 ( 2+5+3=10 odd places)
difference: -3 (7-10)

Thank's!!!
Reply With Quote
  #2  
Old 17-11-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How can i count numbers on odd/even places?

When you scanf() you leave the '\n' on the buffer. Thus, when you call getchar() you get the newline and don't let the user enter something. Your printf() calls need to have a format pattern in the message text. You don't use the "Enter E or e" to quit. The program quits anyhow. You might want to put a while(ch != 'e' || ch != 'E') in your program.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How can i count numbers on odd/even places?"
Thread Thread Starter Forum Replies Last Post
How to change negative numbers to positive numbers in Excel Shaina Na Microsoft Project 3 08-01-2012 05:35 PM
Need C program code to count numbers of negative & positive numbers Sarfaraj Khan Software Development 5 16-01-2010 02:00 PM
How to count numbers from a table in C language MKAIF Software Development 3 01-10-2009 10:34 PM
SQL Query for Searching Missing Numbers from Sequence of Numbers Bhagwandas Software Development 3 18-02-2009 01:47 PM
How to Use Chapter Numbers with Page Numbers In Ms Word Braze Windows Software 3 27-12-2008 07:01 PM


All times are GMT +5.5. The time now is 12:27 PM.