|
|
|
|
Homework 1 |
You can either write your answers to theoretical questions on paper or
edit them in the file hw1/paper.tex. Please show all the
mathematical derivations that you perform.
\n''?
#include <stdio.h> /* for printf and scanf */
int main(void)
{
char *s, string[101];
printf("Input a string: ");
scanf("%100s",string);
/* loop over characters */
for (s=string; *s != ''; s++)
printf("%c",*s);
}
|
Alternatively, modify the following Python script for the same task.
string = input('Input a string: ')
for char in string:
print(char)
|
#include <assert.h> /* for assert */
#include <float.h> /* for DBL_EPSILON */
int main(void)
{
int i;
double eps, one;
eps = 1.0;
for (i=0; i < 100; i++) {
eps /= 2;
one = 1.0+eps;
/* !!! INSERT SOMETHING HERE !!! */
}
assert(DBL_EPSILON==eps);
}
|
Alternatively, modify the following Python script for the same task.
import numpy as np
eps = np.float64(1.0)
for i in range(100):
eps /= 2
one = eps+1.0
# INSERT SOMETHING HERE
DBL_EPSILON = np.finfo(np.float64).eps
assert(DBL_EPSILON == eps)
|
|
|
|
|
Homework 1 |