# Politechnika Śląska - strona 126

## Fahrenheit to Celsius - examples

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

A problem to solve: temperature conversion Fahrenheit Celsius • Gabriel Daniel Fahrenheit introduced a temperature scale in 1714 - Fahrenheit originally defined body temperature as a dozen (12) degrees and an ice/water/salt mixture as 0° F. Later, he divided each degree into 8 parts, obtaining 96° ...

## Ferror - examples

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

Ferror Tests for an error on a stream. int ferror( FILE * stream ); • 0 means: no error has occurred on stream • Otherwise: a nonzero value • The ferror routine tests for a reading or writing error on the file associated with stream • If an error has occurred, the error indicator for the stream rem...

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

Fread • Prototype: size_t fread( void * buffer , size_t size , size_t count , FILE * stream ); • Parameters: buffer Storage location for data size Item size in bytes count Maximum number of items to be read stream Pointer to FILE structure • Reads...

## Functions in C - examples

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

Functions in C A function definition has this form: return-type function-name(paramet er declarations, if any) { declarations statements } Example: /* power: raise base to n-th power; n = 0 */ int power(int base, int n) { int i, p; /* local variab...

## Fwrite - overview

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

Fwrite • Prototype (like fread): size_t fwrite( void * buffer , size_t size , size_t count , FILE * stream ); • Parameters (like fread): buffer Storage location for data size Item size in bytes count Maximum number of items to be read stream Pointer

## High level languages - overview

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

High level languages • 1946: Plankalkul , Konrad Zuse • 1949: Short Code • 1951: A-0 , Grace Hopper • 1957: FORTRAN , John Backus • 1959: LISP • 1958: COBOL • 1960: ALGOL 60 • 1962: APL • 196...

## History - overview

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

History • 1623-24 : Wilhelm Schickard, mechanical calculator • 1642 : Blaise Pascal, adding machine • 1670 : Gottfried Wilhelm Leibnitz, multiplying machine • 1804 : Joseph Marie Jacquard: programmable weaving machine • 1822 :

## Initialization of arrays

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

Initialization of arrays • An array may be initiallized - filled with provided values • Example: int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } • When the array size is omitted: the compiler counts initializers and sets the size t...

## Initialization of pointer arrays

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

Initialization of pointer arrays • Problem: write a function month_name(n) , returning the name of the n -th month (in the form of a pointer to a string) • We will use a static array • month_name contains an array of pointers to 13 strings • … ret...

## Initialization of variables

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

Initialization of variables • A variable may also be initialized in its declaration • Syntax: type name = expression; • Examples: char esc = '\\'; int i = 7*8; int limit = MAXSIZE+1; float eps = 1.0e-5; char msg[] = "warning: "; • For not automatic variables: the initialization is done on...