Politechnika Śląska - strona 319

Character counting 2nd

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 476

Character counting -2nd version #include /* count characters in input; 2nd version */ int main() { long nc; for (nc = 0; getchar() != EOF; nc++) ; /* an empty body of the loop! */ printf("...

Character counting - examples

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 343

Character counting #include /* count characters in input; 1st version */ int main() { long nc; /* used as a counter */ nc = 0; while (getchar() != EOF) nc++; printf("%ld\n", nc); retu...

Dynamic data structures

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 700

Dynamic data structures • A dynamic data structure is a data structure that can change its size and shape during the execution of a program • Examples: - linked list • singly linked list • doubly linked list - graph • tree • heap ...

Dynamic memory allocation

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 532

Dynamic memory allocation • So far, we have always allocated memory while defining variables • What if the amount of memory we need is not known at the compile time ? • Allocate memory at run time ! ...

Forcing conversions - examples

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 385

Forcing conversions • Explicit type conversions - with a unary operator called a cast • In the construction ( type name ) expression the expression is converted to the type name • Example: cels ...

Formatted input and output

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 469

Formatted input and output • fscanf and fprintf • Similar to scanf and printf • The first argument is a file pointer specifying the file to operate on • Prototypes: int fscanf(FILE *fp, char *form...

How to define a language

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 504

How to define a language • An alphabet - a recognizable set of symbols • A set of keywords • A grammar - the rules for using the alphabet to construct sentences and terms in the language • A semantics - the meaning behind the strings formed from the alphabet ...

Initializing multidimensional arrays

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 357

Initializing multi- dimensional arrays • … by a list of initializers in braces • Each row of a two-dimensional array is initialized by a corresponding sub-list • Example: double m[2][3] = {{1.2, 2.3, 3.4}, {5.6, 6.7, 7.8}}; ...

Keywords - overview

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 658

Keywords auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while ...

Negative integers - overview

  • Politechnika Śląska
  • dr inż. Piotr Fabian
  • Fundamentals of Computer Programming
Pobrań: 0
Wyświetleń: 511

Negative integers: why ~0 is -1 • Unsigned 0: 1: 0001 2: 0010 ... 15: • Signed -8: 1000 -2: 1110 -1: 0: 1: 0001 2: 0010 7: 0111 ...