From the course: Debugging C Code
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Challenge: Where is the error? - C Tutorial
From the course: Debugging C Code
Challenge: Where is the error?
(light music) - [Instructor] In 1656, English mathematician, John Wallis, published The Wallis Product, which is this equation, a proof using Euler's infinite product for the sign function. Don't fret. Computers do the math. You just need to plug in the equation. Specifically, I'm looking at this part of the equation, which calculates one half the value of pi. In my nerdy attempt to code a C program that calculates pi, I used the Wallis Product as an inspiration and I've crafted this code. This draft of the program doesn't work. It builds and runs, press the F5 key, but this result here is zero, which according to my barely passing grades in calculus, isn't anywhere near close to pi. So where in here did I goof up? The editor and the compiler offer no clues. For your challenge, I want you to find the error. I recommend you use manual debugging techniques to output variable values as the code runs. This code has two flaws in logic, items that can easily be fixed, but where? Try to find…