Difference: Lecture3:IntroductionToCProgramming (2 vs. 3)

Revision 32017-09-07 - uli

Line: 1 to 1
 
META TOPICPARENT name="LectureSlides"

Start Presentation

Slide 1: A bit of C programming

Line: 59 to 59
 
  • enum
And you can define your own data types with typedef
Deleted:
<
<

 

Assignements

Changed:
<
<
We modify the program to do some calculation:

>
>
We modify the program to do some calculation:


assignement.png

Calculating the Fibonacci numbers

The Fibonacci numbers:

0 1 1 2 3 5 8 13 21 34 …

or xn = xn-1+xn-2

How can we write a program to calculate up to 12 such numbers?

This can easily be done in a for loop

The for loop

fibonacci.png

The while loop

Can we also do calculations as long as the Fibonacci number

does not exceed a certain value?

while.png

Pointers

We can define variables which do not contain the value but

the address of where the value is stored in memory:


char a=5; is the value


char *myText=”Hello World!”;

myText points to the place in memory where Hello World is stored.

Pointer Example

pointerExample.png

  %SLIDESHOWEND%
Line: 79 to 123
 
META FILEATTACHMENT attachment="switch-1.png" attr="" comment="" date="1504775835" name="switch-1.png" path="switch-1.png" size="23707" user="uli" version="1"
META FILEATTACHMENT attachment="switch-2.png" attr="" comment="" date="1504775835" name="switch-2.png" path="switch-2.png" size="34389" user="uli" version="1"
META FILEATTACHMENT attachment="questionRes.png" attr="" comment="" date="1504775904" name="questionRes.png" path="questionRes.png" size="8264" user="uli" version="1"
Added:
>
>
META FILEATTACHMENT attachment="assignement.png" attr="" comment="" date="1504792877" name="assignement.png" path="assignement.png" size="30988" user="uli" version="1"
META FILEATTACHMENT attachment="typeError.png" attr="" comment="" date="1504792877" name="typeError.png" path="typeError.png" size="10701" user="uli" version="1"
META FILEATTACHMENT attachment="typeCast.png" attr="" comment="" date="1504792877" name="typeCast.png" path="typeCast.png" size="24274" user="uli" version="1"
META FILEATTACHMENT attachment="fibonacci.png" attr="" comment="" date="1504793137" name="fibonacci.png" path="fibonacci.png" size="30690" user="uli" version="1"
META FILEATTACHMENT attachment="while.png" attr="" comment="" date="1504793320" name="while.png" path="while.png" size="26008" user="uli" version="1"
META FILEATTACHMENT attachment="pointerExample.png" attr="" comment="" date="1504793514" name="pointerExample.png" path="pointerExample.png" size="41661" user="uli" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback