Urgent Programming Problem

This is a discussion on Urgent Programming Problem within the C Programming forums, part of the General Programming Boards category; I have an assignment due, and I have no clue what to do. I've read up on the subject and ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    2

    Exclamation Urgent Programming Problem

    I have an assignment due, and I have no clue what to do. I've read up on the subject and still am not sure what to do. Here is the problem:
    1.) Write a C program (name it integer.c) that asks the user to input a single integer and then reports back to the user whether the integer is positive, negative, or zero. In addition, if the integer is positive, report whether it is even or odd. If it is even, find and report the largest power of 2 that evenly divides the integer. Place this program and the others for this assignment in a subdirectory off your home directory on et791. Name this subdirectory assign13.

    AND

    2.) Write an interactive C program (name it real.c) that asks the user for an integer n (that represents the number of real numbers to be processed), then ask the user to enter n real numbers (numbers with decimal places), and then calculate and report the sum and product of these real numbers. Repeat this process until the user chooses to stop.

    If someone could please help me that would be extremely helpful. Thanks, Mike.

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    61
    Post the code that you have so far.
    $ENV: FreeBSD, gcc, emacs

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    2

    the code i have so far

    I have no clue on where to even start the code..............

  4. #4
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    Did you attend a class or something to get to this no clue stage? Most houses of learning teach you what you need to know or show you where to get the information before having you do exercises to reinforce idea's & concepts.

    How about you white some pseudo code? Or even start the framework of the program? Define some variables? This is a help forum, not a 'We'll do all the work for every lazy bum that comes along' forum.
    Demonographic rhinology is not the only possible outcome, but why take the chance

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    85
    You could start by creating integer.c. First, ask the user for a number [scanf("%d",&my_int);]. Then, do some checking on that number to see if it's pos, neg...
    Code:
    if( my_int > 0 )
       puts("It's positive!");
    if( my_int < 0 )
       puts("It's negative!");
    if( my_int == 0 )
       puts("It's zero!");
    Of course there are better ways to do that, but that's just the basic idea. The even/odd thingy requires a little more thinking. Aha, every even number is divisible by two, with no remainder. To find the remainder of our int divided by two, we can use our friend mr. modulus (%).
    Code:
    if( my_int % 2 == 0 )
       puts("It's even!");
    if( my_int % 2 != 0 )
       puts("It's odd!");
    That's enough to get you started, hopefully.. If not, oh well, I need to sleep

  6. #6
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,157
    Actually, start with your hello.c program, remove the "hello" part, and start adding code.

    You've described the assignment. Now write down the steps you would take to do it on paper. Then translate that into the code you've been taught.

    How do you input values?
    How do you test values?
    How do you write values to screen?
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation Fault Problem: Urgent Help
    By bodydrop in forum C Programming
    Replies: 3
    Last Post: 05-05-2006, 08:02 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  3. Problem in loop. Please Help. Urgent!
    By jjbuchan in forum C Programming
    Replies: 4
    Last Post: 11-10-2005, 03:46 PM
  4. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  5. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21