CS137 Study Guide - Midterm Guide: Scientific Notation, Scilab, C Data Types

149 views7 pages

Document Summary

Gcd int gcd (int a, int b) int r= a%b; while (r!=0) a=b; b=r; r=a%b; return b; Horner"s method double horner (double f[], int n, double x) // f[0]=2. 0, f[1]=9. 0, f[2]=4. 0, f[3]=3. 0 n=4 assert (n>0); double h = f[n-1]; for (int i=n-2; i>=0; i--) return h; h=h*x + f[i]; return x-cos(x); Bisection double f (double x) double bisect (double a, double b, double epsilon, int maxiters) assert (f(a)<0. 0 && f(b)>0. 0 && epsilon > 0. 0); double m; for (int i=0; i0) else b=m; a=m; return m; Primes bool isprime (int num) int divisor = 2; if (num<=1) return false; else while (num/divisor >= divisor) if (num%divisor)==0) return false; divisor++; return true; Type unsigned char char unsigned short int short int unsigned int int unsigned long int long int unsigned long long int long long int.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents