01.11.2014 Views

Lesson 1.1: Hello, world

Lesson 1.1: Hello, world

Lesson 1.1: Hello, world

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Lesson</strong> 1.7:<br />

Functions<br />

Programming in C<br />

Prof. Dr. Eike Best<br />

Dr. Elke Wilkeit<br />

September 28, 2002<br />

1 #include <br />

2<br />

3 int power(int m, int n);<br />

4<br />

5 /* test power function */<br />

6 main()<br />

7 {<br />

8 int i;<br />

9<br />

10 for (i = 0; i < 10; ++i)<br />

11 printf("%d %d %d\n", i, power(2,i), power(-3,i));<br />

12 return 0;<br />

13 }<br />

14<br />

15 /* power: raise base to n-th power; n>=0 */<br />

16 int power(int base, int n)<br />

17 {<br />

18 int i,p;<br />

19<br />

20 p = 1;<br />

21 for (i = 1; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!