Help me in completing a program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kalyankiran33
    New Member
    • Dec 2006
    • 1

    Help me in completing a program

    I have com across a program in which I should take 17 as a global constant.
    I have to take 17 inputs.
    for those inputs ..
    I have to find
    the number of even numbers entered
    the number of odd numbers entered
    the number of prime numbers entered
    smallest number among those 17
    largest number among those 17
    factorial of the smallest number
    the first number
    the last number
    power of the first number and the last number

    These should come under a single main function.
    I have done
    number of even
    number of odd
    number of prime

    I am finding some difficulties in finding
    largest and smallest numbers
    The main problem is I should not use arrays as well as any other functions for these..
    So without using arrays
    I have to find a solution..
    Please can u help me in finding a solution using for loops,while loops
    etc.
  • vpawizard
    New Member
    • Nov 2006
    • 66

    #2
    For largest, take a variable x containing -inf (theorotically, practically lowest number data type supports). Compare each of 17 elements with x. If element is greater than x, store it in x and proceed.

    Comment

    • nachu
      New Member
      • Dec 2006
      • 15

      #3
      Hope U Can Have A Variable (say Val).
      1.store The First Number U Get As Input In It.
      2.then After Getting The Next Number Check If It Is Greater Than Val, If It Is Exchange The Values.
      3.repeat This For Every 17 Numbers Or So....
      4.you Can Do The Vice-versa For The Lowest Number By Checking For <.

      Try It..hope It Will Work..

      Comment

      • thefarmer
        New Member
        • Nov 2006
        • 55

        #4
        Originally posted by kalyankiran33
        I have com across a program in which I should take 17 as a global constant.
        I have to take 17 inputs.
        for those inputs ..
        I have to find
        the number of even numbers entered
        the number of odd numbers entered
        the number of prime numbers entered
        smallest number among those 17
        largest number among those 17
        factorial of the smallest number
        the first number
        the last number
        power of the first number and the last number

        These should come under a single main function.
        I have done
        number of even
        number of odd
        number of prime

        I am finding some difficulties in finding
        largest and smallest numbers
        The main problem is I should not use arrays as well as any other functions for these..
        So without using arrays
        I have to find a solution..
        Please can u help me in finding a solution using for loops,while loops
        etc.

        hi there,

        it seems that we are very willing to help you, but for now i strongly suggest that you post something, coz some people here are too busy to encode codes from the scratch, so post something and we'll see..
        ok

        regards,

        Comment

        Working...