(a>b?a:b)
?
creall
function?
echo $0
echo $SHELL
ps --pid "$$"
complex.h
, do you
need to link your program with -lm
option? Hint: man
complex
.
apropos complex | grep functionHint: you might need to
sudo apt-get install manpages-posix manpages-posix-dev
; the bar in the command is the pipeline;
grep searches for given text.
int i=1; printf("%i\n",i++); printf("%i\n",++i);
Explain.
int i=1; printf("%i %i\n",i++,++i);
? Hint:
compile with -Wall
.
while(condition)body
using the for
loop.
for(init;cond;inc)body
using the while
loop.
do body while(condition);
using the for
loop.
limits.h
and
float.h
define certain useful limits.
i
for which i+1>i
holds true.
Now, using the while
loop determine your maximum integer and
compare it with the value INT_MAX
defined in
limits.h
. Hint: something like
int i=1; while(i+1>i) {i++;}
Now do the same with the for
loop and do while
loop. It may take about a dozen seconds to calculate depending on your
hardware.
i
for which i-1<i
holds
true. Now, using the while
loop determine your minimum
integer and compare with the value INT_MIN
defined
in limits.h
. Do the same using the for
loop and
do while
loop.
while
loop
calculate the machine epsilon for types float, double, and long double,
and compare with the values FLT_EPSILON, DBL_EPSILON, and LDBL_EPSILON defined
in float.h
. Hint:
double x=1; while(1+x!=1){x/=2;} x*=2;
Do the same using the do while
loop and for
loop. Hint:
double e; for(e=1; 1+e!=1; e/=2){} e*=2;
Remember to use %Lg
format placeholder for long double
numbers.
int max=INT_MAX/2;
(or, say,
INT_MAX/3
, if
the execution time is longer than you are willing to wait)
float sum_up_float = 1.0f + 1.0f/2 + 1.0f/3 + ... + 1.0f/(max-1);
and another sum
float sum_down_float = 1.0f/(max-1) + 1.0f/(max-2) + 1.0f/(max-3) + ... +1.0f;
with float
type and
compare the two sums.
max
?
sum_up_double
and sum_down_double
using double
type. Explain the result.
void
(that is, it does not return
anything) with one argument of type int
, which in the case
when the argument is 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9 prints out the name of the
digit, correspondingly "zero", "one", "two", ... , "nine"; and prints "not
a digit" in the case of other arguments. Use the switch
construction. The signature of the function is void name_digit(int
i)
.