A tutorial Introduction Flashcards
Pointers in C:
Pointers provide for machine independent address Arithmetic.
A function definition may not be nested but variables may be declared in a block-structured manner.
Meaning?
What all stuff does C offer?
and not offer?
Offers only straightforward, single-thread control flow: tests, grouping, and subprograms.
But not multiprogramming, parallel operation, synchronisation, or coroutines.
Why is the run time lib req to implement self-contained programs tiny?
As the data type and control structures provided by C are supported by most computers, the run-time lib required to implement self-contained programs is tiny.
C and machine architectures..
C does match capabilities of many comp, but its independent of machine architecture, Easy to write portable programs (i.e program that can be run without change in
The standard makes portability issues explicit and prescribes a set of constants that characterize the machine on which the program is run.
Means?
Blemishes of C?
- Wrong operator precedence. which?
2. Some parts of syntax could be better. which?
printf(“Hello!
“);
Output?
Error.
printf() never supplies newline automatically.
\n how many characters?
1
Where can comments occur?
ignored by the compiler. They can occur where blanks or tab or newline.
whats wrong with int i = 0; int C = 0; C = (5/9)*(i - 32); how to make it work?
C = 5*(i-32)/9 works.
multiplying by 5 and then dividing by 9 works.
but multiplying by (5/9) does not work as its int, int division truncates: any fractional part is discarded.
To make it work, work in floating point. 5.0/9.0 will not truncate to zero.
how does printf print %?
%%
The genral rule, eliminating variables kinda…:
In any context where it is permissible to use the value of a variable of some type, u can use a more complicated expression of that type.
Choice of for and while.. comment on use:
The “for” is usually appropriate for loop in which initialisation and testing are single statements and logically related since it’s more compact than while it keeps the loop control statements together at one place.
Magic Numbers use?
Symbolic Constants.
It's bad practise to use constants, less readable program. We can use #define name replacementText It defines a particular symbolic constant to be a string of char.