Computer Programming Oel Abdullah
Computer Programming Oel Abdullah
EE-163
PROBLEM 1
PRE CODING PLANS
Pre-Program Plan for Halley's Method Code:
o Uses a loop to update the guess using Halley's formula until the desired
precision is reached.
• In main(), take input from the user and put in halleys method.
CODE
#include <iostream>
#include <cmath>
Page | 1
double f_prime(double x, double a, double b, double c) {
double x1;
do {
break;
x0 = x1;
} while (true);
return x1;
int main() {
double a, b, c, d, x0;
Page | 2
cin >> a >> b >> c >> d;
cout << "Root of the equation: " << root << endl;
return 0;
IMAGES
Page | 3
PROBLEM 2
PRE CODING PLANS
• Input: Value of angle x in radians.
• Initialize: First term as x, sum as x, start n=1.
• Iterate: Compute next term using the previous term to avoid recomputation of
powers and factorials.
• Terminate: When |term| < 0.0001.
CODE
#include <iostream>
#include <cmath>
int main() {
int n = 1;
cin >> x;
Page | 4
term *= -1 * x * x / ((2 * n) * (2 * n + 1));
sum += term;
n++;
cout << "sin(" << x << ") = " << sum << endl;
return 0;
IMAGES
Page | 5