Another loop question

This is a discussion on Another loop question within the C Programming forums, part of the General Programming Boards category; this is what i have done with my program but the value of the sum is not coming up and ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    62

    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:

    5+7+9+11

    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

    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<stdlib.h>
    
    
    main()
    {
          int a,b,c,t;
          scanf("%i%i%i",&a,&b,&c);
          for (a>=5;a<=11;a+=2)
          
          {
               
               printf("\n%i",a );
              
        
           }
    
    
      getch();
    
    }
    Last edited by joker_tony; 03-22-2008 at 06:32 PM.

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

    --
    Mats
    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
    Posts
    62
    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, 09:39 AM
  2. Loop question
    By kwood965 in forum C Programming
    Replies: 6
    Last Post: 10-30-2008, 12:12 AM
  3. simple for loop function question
    By felicityxiv in forum C Programming
    Replies: 7
    Last Post: 05-07-2006, 12:43 AM
  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, 06:13 PM

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