UNIT 3 Programming Concepts
UNIT 3 Programming Concepts
#Environment Setup
Link for downloading VS code
https://www.youtube.com/watch?v=JGsyJI8XG0Y
# Language levels
1. When computers were first developed, the only way to program them was
in terms of binary numbers. These binary numbers corresponds to
machine instructions and referred to as Machine language and are stored
in computer’s memory. The next step in programming was the
development of assembly languages.
2. The assembly language permits the programmer to use symbolic names
to perform various operations. An assembler translates the assembly
language program into the machine instructions i.e in binary. Assembly
language programs are written in terms of seperate instruction sets, they
are machine dependent.
3. The machine language and the assembly language is popularly known as
Low level language.
4. Higher-level language was introduced so that a program could be written
in the language to be machine independent.
5. A special computer program must be developed that translates the
statements of the higher-level language into a form that the computer can
understand. This program is known as a compiler.
6. Program development stages
Compiler :To start the compilation process, the file containing the source C
program must be specified. Compiler examines each program statement present
in the source programs for correct syntax and semantics of the language. If there
are any mistakes or errors detected by the compiler then these are reported to
the user and compilation process is terminated. The errors must be removed
from the source program and then compilation process may be reinitiated. Once
all the errors have been removed then compiler restarts it process. Compiler
takes the statements of the program and translates it into lower language.
C Character Set
As every language contains a set of characters used to construct words,
statements, etc., C language also has a set of characters which
include alphabets, digits, and special symbols. C language supports a total of
256 characters.
1. Alphabets
2. Digits
3. Special Symbols
Alphabets
C language supports all the alphabets from the English language. Lower and
upper case letters together support 52 alphabets.
lower case letters - a to z
UPPER CASE LETTERS - A to Z
Digits
C language supports 10 digits which are used to construct numerical values in C
language.
Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special Symbols
C language supports a rich set of special symbols that include symbols to
perform mathematical operations, to check conditions, white spaces,
backspaces, and other special symbols.
Special Symbols - ~ @ # $ % ^ & * ( ) _ - + = { } [ ] ; : ' " / ? . > , < \ | tab
newline space NULL bell backspace verticaltab etc.,
Every character in C language has its equivalent ASCII (American Standard
Code for Information Interchange) value.
C Tokens
Every C program is a collection of instructions and every instruction is a
collection of some individual units. Every smallest individual unit of a c
program is called token. Every instruction in a c program is a collection of
tokens. Tokens are used to construct c programs and they are said to the basic
building blocks of a c program.
1. Keywords
2. Identifiers
3. Operators
4. Special Symbols
5. Constants
6. Strings
7. Data values
C Keywords
As every language has words to construct statements, C programming also has
words with a specific meaning which are used to construct c program
instructions. In the C programming language, keywords are special words with
predefined meaning. Keywords are also known as reserved words in C
programming language.
Properties of Keywords
Some examples are int, short, signed, unsigned, default, volatile, float, long,
double, break, continue, typedef, static, do, for, union, return, while, do, extern,
register, enum, case, goto, struct, char, auto, const etc.
C Variables
Variables in a c programming language are the named memory locations where
the user can store different values of the same datatype during the program
execution.
Every variable in c programming language must be declared in the declaration
section before it is used. Every variable must have a datatype that determines
the range and type of values be stored and the size of the memory to be
allocated.
Declaration of Variable
Declaration of a variable tells the compiler to allocate the required amount of
memory with the specified variable name and allows only specified datatype
values into that memory location. In C programming language, the declaration
can be performed either before the function as global variables or inside any
block or function. But it must be at the beginning of block or function.
Declaration Syntax:
datatype variableName;
Example
int number;
C data types
Data used in c program is classified into different types based on its properties.
In the C programming language, a data type can be defined as a set of values
with similar characteristics. All the values in a data type have the same
properties.
Data types in the c programming language are used to specify what kind of
value can be stored in a variable. The memory size and type of the value of a
variable are determined by the variable data type. In a c program, each variable
or constant or array must have a data type and this data type specifies how much
memory is to be allocated and what type of values are to be stored in that
variable or constant or array.
In the c programming language, data types are classified as follows...
float
double