100% Guaranteed Results


EE231002 Introduction to Programming Solved
$ 20.99
Category:

Description

5/5 – (1 vote)

Lab02. Pi and sine function
The number π is known to be an irrational number and cannot be expressed exactly in decimal format. The decimal value, however, can be approximated. Many approximation formulae have been developed. One of them is shown below.
(2.1)
Though not the most accurate, we assume the value of π can be calculated using the 6-term series on the right hand side.
The trigonometric function sin(x) can also be approximated using infinite series as shown below.
(2.2)
(2.3)
For this lab, we assume sin(x) can be approximate accurately using 4-term series as above.
In this lab, please write a C program to find the value of π and sin . The output of the program should be as following:

$ ./a.out pi = x.xxxxx sin(pi/6) = x.xxxxxx

Notes.
1. Create a directory lab02 and use it as the working directory.
2. Name your program source file as lab02.c.
3. The first few lines of your program should be comments as the following.
*/
4. After finishing editing your source file, you can execute the following command to compile it,
$ gcc lab02.c
If no compilation errors, the executable file, a.out, should be generated, and you can execute it by typing
$ ./a.out
5. After you finish verifying your program, you can submit your source code by
$ ∼ee231002/bin/submit lab02 lab02.c
If you see a ”submitted successfully” message, then you are done. In case you want to check which
1
file and at what time you submitted your labs, you can type in the following command:
$ ∼ee231002/bin/subrec
It will show the last few submission records.
6. Since loops have not been covered yet, do not use loops in this lab. And because no loops, program efficiency is not the best. Thus, for this lab only, the efficiency is not emphasized.
2

Reviews

There are no reviews yet.

Be the first to review “EE231002 Introduction to Programming Solved”

Your email address will not be published. Required fields are marked *

Related products