Professional Documents
Culture Documents
Computer
- is an electronic device that accepts data from the user, processes it,
produces results, displays them to the users, and stores the results for
future usage
Data
- is a collection of unorganized facts & figures and does not provide any
further information regarding patterns, context, etc. Hence data means
"unstructured facts and figures".
Information
- is a structured data i.e. organized meaningful and processed data. To
process the data and convert into information, a computer is used.
Functions of Computers
Input
Process
Store
Output
7 Characteristics of Computer System
1. Memory
2. Automation
3. Reliability
4. Versatility
5. Diligence
6. Accuracy
7. Speed
Basic Application of Computer
Home
Medical Field
Entertainment
Industry
Education
Government
Banking
Business
Training
Arts
Science & Engineering
Constants
- an entity that doesn’t change
Variable
- An entity that may change
Types of C constants
a. Primary Constants
Integer Constant
Real Constant
- Often called Floating point constants
- Could be written in two forms
Fractional form
Exponential Form
Character Constant
- A character constant is a single alphabet, a single digit, or a
single special symbol enclosed within single inverted
commas
- Both inverted commas should point to the left
b. Secondary Constants
Array
Pointer
Structure
Union
Enum, etc.
Types of Variables in C
1. local variable
- declared inside the function or block
2. global variable
- declared outside the function or block. Any function can change
the value of global variable – it is available to all the functions
3. static variable
- declared with static keyword. It retains its value between multiple
function calls
4. automatic variable
- all variable in c that are declared inside the block are automatic
variable by default. We can explicitly declare an automatic variable
using auto keyword
5. external variable
- can share a variable in multiple C source files. To declare an
external variable, you need to use an external keyword
Rules in constructing C variable names
a. A variable name is any combination of 1 to 31 alphabets, digits, or
underscores. Some compilers allow variable names whose length could
be up to 247 characters. Still, it would be safer to stick to the rule of 31
characters.
b. First character in the variable name must be an alphabet or underscore
c. No commas or blanks are allowed within a variable name
d. No special symbol other than an underscore (as in gross_sal) can be used
in a variable name
Variable Declaration
- A statement in which a variable is stored by the compiler.
- <data type> <variable name>;
<data type> <variable name> = <variable initial value>;
Type Casting
- The different ways of changing an expression from one data type to
another.
Executable Statements
- Specify the actions to be performed during the execution of program
code.
- are normally executed in the sequence they appear in the program code.
C Arithmetic Expressions
Precedence
- the NOT (!) operator has the highest precedence and it associates from
right to left. The precedence of AND (&&) operator is higher than OR (||)
operator and they both associates from left to right.
The if statement
- a non-zero value is considered to be true, whereas a zero is considered to
be false
- The group of statements after the if up to and not including the else is
called an ‘if block’. Similarly, the statements after the else form the ‘else
block’.
- Notice that the else is written exactly below the if. The statements in the
if block and those in the else block have been indented to the right. This
formatting convention is followed throughout the book to enable you to
understand the working of the program better.
- Had there been only one statement to be executed in the if block and
only one statement in the else block we could have dropped the pair of
braces.
- Had there been only one statement to be executed in the if block and
only one statement in the else block we could have dropped the pair of
braces.