Thread: Help on Starting a Program!

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

    Help on Starting a Program!

    Hi, I have an exam in a few days and I have no idea where to start with writing this program, I have looked at my notes and I have no idea how to starts. Could someone give me a hand with how to start off, I would really appreciate it. I'm not asking for you to do my homework, I just need to know where to start so I can use it as practice to study for my exam. Many thanks!

    Instructions:



    1. Read your notes concerning loops with particular attention to while and for loops.
    2. Write the pseudocode (algorithm) for the following program definition: The German mathematician Gottfried Liebniz developed the following method to approximate the value of pi:
      pi/4 = 1 - 1/3 + 1/5 - 1/7 + ...
      Write a program that allows the user to specify the number of iterations used in this approximation and that displays the resulting value.

    During the lab:

    1. Using Quincy, write the C program based on your algorithm.
    2. Eliminate the syntax errors.
    3. Run your program and test it.
    4. Debug your program if necessary until you get correct results.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Err... start by "read(ing) your notes concerning loops with particular attention to while and for loops"?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Review the formula someplace, like Wikipedia:
    Leibniz formula for

    Then study how you would do it, and use a correct implementation to compare with:
    mattst88's leibniz pi code

    REALLY get to know it like the back of your hand - maybe better!

  4. #4
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by Sharpenel View Post
    Hi, I have an exam in a few days and I have no idea where to start with writing this program, I have looked at my notes and I have no idea how to starts. Could someone give me a hand with how to start off, I would really appreciate it. I'm not asking for you to do my homework, I just need to know where to start so I can use it as practice to study for my exam. Many thanks!

    Instructions:



    1. Read your notes concerning loops with particular attention to while and for loops.
    2. Write the pseudocode (algorithm) for the following program definition: The German mathematician Gottfried Liebniz developed the following method to approximate the value of pi:
      pi/4 = 1 - 1/3 + 1/5 - 1/7 + ...
      Write a program that allows the user to specify the number of iterations used in this approximation and that displays the resulting value.

    During the lab:

    1. Using Quincy, write the C program based on your algorithm.
    2. Eliminate the syntax errors.
    3. Run your program and test it.
    4. Debug your program if necessary until you get correct results.
    Start like this:

    Code:
    #include <stdio.h>
    
    int main(void)
    {
      /* Logic goes in here */
      return 0;
    }
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Starting a new program
    By histevenk in forum C++ Programming
    Replies: 28
    Last Post: 10-15-2007, 04:11 PM
  2. Starting a program
    By mcgeady in forum C++ Programming
    Replies: 3
    Last Post: 02-25-2006, 12:52 PM
  3. starting program
    By Ideswa in forum C++ Programming
    Replies: 3
    Last Post: 02-20-2006, 02:36 PM
  4. Starting a Program, use C or C++?
    By firestorm in forum Windows Programming
    Replies: 12
    Last Post: 04-11-2005, 09:07 PM
  5. Starting the program
    By vasanth in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 04:51 AM