Thread: Another loop question

  1. #1
    Registered User
    Join Date
    Feb 2008

    Another loop question

    this is what i have done with my program but the value of the sum is not coming up and i need help on this.
    this is what the program should supposed to do

    write a program to calculate the sum of numbers. the user enter the starting number, the largerst number. and the step size of the numbers to be added. For example, if the user enters 5 12 2. the program will calculate the sum of:


    and it should input the TABLE of values in the format shown below:

    PHP Code:
    VALUE      SUM
    5          5
    7          12
    9          21
    11         32 

    The sum of the number is 32

          int a,b,c,t;
          for (a>=5;a<=11;a+=2)
               printf("\n%i",a );
    Last edited by joker_tony; 03-22-2008 at 05:32 PM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
         for (a>=5;a<=11;a+=2)
    This should probably be:
         for (a=5;a<=11;a+=2)
    But you are also not performing any calculation in the loop.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Feb 2008
    i dont understand what kind of calculation i should make, but what i know is taht there should be a function that will scanf 3 numbers and call to main

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. For loop question
    By JuzMe in forum C++ Programming
    Replies: 11
    Last Post: 04-20-2009, 08:39 AM
  2. Loop question
    By kwood965 in forum C Programming
    Replies: 6
    Last Post: 10-29-2008, 11:12 PM
  3. simple for loop function question
    By felicityxiv in forum C Programming
    Replies: 7
    Last Post: 05-06-2006, 11:43 PM
  4. Please don't laugh...SIMPLE loop question!
    By the_lumin8or in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2006, 01:08 PM
  5. while loop question
    By rayrayj52 in forum C++ Programming
    Replies: 2
    Last Post: 10-19-2004, 05:13 PM