Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C programming HELP!!

Name: Ahh 2012-05-21 1:48

How do I make the following code using C programming:
Create a program that has the following fields & capabilities:

fields:

type purpose
int Storage for the target sum

methods

name return type purpose parameter(s)
main void Gets the target sum from the user
and then calls getSeries. none
getSeries void Determines the first and last integers in EVERY series of positive, consecutive INTEGERS whose sum is the target sum. Output sent to System.out object. none

For example, if the target sum is 30, your program would output the following:
THE FIRST AND LAST NUMBERS IN EVERY SERIES OF POSITIVE, CONSECUTIVE INTEGERS WHOSE SUM IS 30 ARE:
4...8
6...9
9...11

Name: Ahh 2012-05-21 2:15

So...please don't make fun of me, this is what I have so far.. I am a super beginner at programming.

#include <stdio.h>
#include <stdlib.h>


 int targetSum;

int getSeries(void)
{

      targetSum = 30;
   printf("The first and last numbers in every series of\n "
         "positive consecutive integers whose sum is ");
        printf("%d are: \n", targetSum);

        int length;
        for(length = sqrt(targetSum); length > 0; length--)
         {
         if (targetSum % length == (length & 1) * (length / 2))
    targetSum = targetSum * 2 / length - (length - 1) / 2 + "..." + targetSum * 2 / length + (length - 1) / 2;
         printf("%d",targetSum);

        }

     return getSeries;
    }

Name: ahh 2012-05-21 2:23

i changed it a little bit but only "THE FIRST AND LAST NUMBERS IN EVERY SERIES OF POSITIVE, CONSECUTIVE INTEGERS WHOSE SUM IS 30 ARE:" shows. What did I do wrong?


#include <stdio.h>
#include <stdlib.h>
#include <math.h>


 static int targetSum;

int main(void)
{

        targetSum = 30;
        printf("The first and last numbers in every series of\n "
         "positive consecutive integers whose sum is ");
        printf("%d are: \n", targetSum);



}

int getSeries(void)
    {
       int length;
        for(length = sqrt(targetSum); length > 0; length--)
          {
         if (targetSum % length == (length & 1) * (length / 2))
     targetSum = targetSum * 2 / length - (length - 1) / 2 + "..." + targetSum * 2 / length + (length - 1) / 2;
         printf("",targetSum);

            }

    }return getSeries;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List