A tutorial Introduction Flashcards

1
Q

Pointers in C:

A

Pointers provide for machine independent address Arithmetic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A function definition may not be nested but variables may be declared in a block-structured manner.

A

Meaning?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What all stuff does C offer?

and not offer?

A

Offers only straightforward, single-thread control flow: tests, grouping, and subprograms.
But not multiprogramming, parallel operation, synchronisation, or coroutines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is the run time lib req to implement self-contained programs tiny?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

C and machine architectures..

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The standard makes portability issues explicit and prescribes a set of constants that characterize the machine on which the program is run.

A

Means?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Blemishes of C?

A
  1. Wrong operator precedence. which?

2. Some parts of syntax could be better. which?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

printf(“Hello!
“);
Output?

A

Error.

printf() never supplies newline automatically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

\n how many characters?

A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Where can comments occur?

A

ignored by the compiler. They can occur where blanks or tab or newline.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
whats wrong with
int i = 0;
int C = 0;
C = (5/9)*(i - 32);
how to make it work?
A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

how does printf print %?

A

%%

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The genral rule, eliminating variables kinda…:

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Choice of for and while.. comment on use:

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Magic Numbers use?

Symbolic Constants.

A
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly