Hacettepe University Department Of Computer Engineering Bil137 Programming Laboratory Experiment 2Submission Date : 27.10.2009 Due Date : 10.11.2009 Advisors : Oğuz ASLANTÜRKR.A. Seda TANKIZ Programming Language : C INTRODUCTION You have learned flow charts, control structures (If-else), repetitive structures or loops (while, for) during course sessions. In order to impact what you learned so far, you are asked to write a program in C programming language. There are fifteen questions below and you are supposed to answer just one of them. You can find out which question you are going to answer in the list at the end of this document. Please pay attention submission and restriction section of this paper. OBJECTIVES Assignment, Increment and Decrement Operators Arithmetic expressions Control Structures: if and if/elseRepetition Structure: WHILE, FOR Type casting QUESTIONS 1.Calculate the value of π from the infinite series :π = 4 - (4/3) + (4/5) - (4/7) + (4/9) - (4/11) + ...........Your program should ask for an iteration value and do the calculation for that number of iterations. For example : If iteration = 0 then result is 4 If iteration = 1 then result is 4 - (4/3) If iteration = 2 then result is 4 - (4/3) + (4/5) 2. Write a program that estimates the value of the mathematical constant e by using the formula: The number of iterations will vary according to the input value. Your program is supposed to work for any value between 1-20, so do not forget to include long values.
This preview has intentionally blurred sections.
Sign up to view the full version.