Difference: Lecture3:IntroductionToCProgramming (3 vs. 4)

Revision 42017-09-08 - uli

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

Start Presentation

Slide 1: A bit of C programming

Line: 33 to 33
  “Hello World” program
Changed:
<
<
#include <stdio.h>

void main() {

printf(“Hello World!\n”);

}

>
>
hello.png
 
Let us try to compile and execute this program
Line: 59 to 53
 
  • enum
And you can define your own data types with typedef
Changed:
<
<

Assignements

>
>

Assignments

  We modify the program to do some calculation:


assignement.png

Added:
>
>

Conditions: the if statement

Conditions can be tested with if

if (a < b)

printf(“a is bigger than b\n”);

else

printf(“b is bigger than a\n”);

 

Calculating the Fibonacci numbers

The Fibonacci numbers:

Line: 108 to 116
 

Pointer Example

pointerExample.png

Added:
>
>

Command line arguments

The main routine has 2 parameters, which we did not use

yet as well as a return code.

int main(int argc, char ** argv) or

int main(int argv, char *argv[ ]);

int argc is the number of arguments passed

char **argv is a pointer to a list of null terminated C strings.

Command line arguments example

 %SLIDESHOWEND%

-- Uli Raich - 2017-09-07

Line: 129 to 155
 
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"
Added:
>
>
META FILEATTACHMENT attachment="hello.png" attr="" comment="" date="1504889659" name="hello.png" path="hello.png" size="7576" user="uli" version="1"
META FILEATTACHMENT attachment="lecture_3.odp" attr="" comment="" date="1504890075" name="lecture_3.odp" path="lecture_3.odp" size="442239" 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