Results 1 to 2 of 2

Thread: How can i count numbers on odd/even places?

  1. #1
    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!!!

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    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.

Similar Threads

  1. How to change negative numbers to positive numbers in Excel
    By Shaina Na in forum Microsoft Project
    Replies: 3
    Last Post: 08-01-2012, 05:35 PM
  2. Need C program code to count numbers of negative & positive numbers
    By Sarfaraj Khan in forum Software Development
    Replies: 5
    Last Post: 16-01-2010, 02:00 PM
  3. How to count numbers from a table in C language
    By MKAIF in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 10:34 PM
  4. SQL Query for Searching Missing Numbers from Sequence of Numbers
    By Bhagwandas in forum Software Development
    Replies: 3
    Last Post: 18-02-2009, 01:47 PM
  5. How to Use Chapter Numbers with Page Numbers In Ms Word
    By Braze in forum Windows Software
    Replies: 3
    Last Post: 27-12-2008, 07:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,105,498.02420 seconds with 17 queries