



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




/functions.c Using some built in functions. Using the locals window to observe values. / #include<stdio.h> /scanf, printf/ #include<stdlib.h> /STANDARD LIBRARY abs(int)/ #include<math.h> /MATH FUNCTIONS: ceil(double), cos(double), exp(double), fabs(double), floor(double), log(double), log10(double), pow(double,double), sin(double), sqrt(double), tan(double), and more / int main() { /declare variables/ int m = 4, n = -3, k = 0; double pi = 3.14159, e = 2.71828, two = 2.0, x; double z;
/absolute value for integers and for doubles 2/ k=abs(m); k=abs(n); z=fabs(pi); z=fabs(pi-10.0);
/ceiling and floor return the integer part of the number (as a double)/ z=ceil(pi); z=ceil(e); z=floor(pi); z=floor(e);
/* functions to computer power (exponent) and squareroot/ z=twotwo*two; z=pow(two,3.0); z=pow(two,-3.0); z=sqrt(4.0); z=sqrt(two);
return 0;
/* printbox.c / / Given a size from the user, print a box with that many spaces in
/* Get the input size from the user */ printf("Type in the size of the interior of the box in each dimension> \n"); scanf("%i", &size); printf("\n");
/* print the top border with a loop of size + 2 underbars / for (j = 1; j <= (size+2); j++) { printf("_"); } / go to next line */ printf("\n");
/* print the interior lines of the box / / first loop over the number of lines, which is size / for (i = 1; i <= size; i++) { / print the left border character / printf("|"); / now loop over the size of the interior, printing spaces / for (j = 1; j <= size; j++) { printf(" "); } / print the right border character and go to the next line */ printf("|\n"); }
/* print the bottom border with a loop of size + 2 underbars */