0% found this document useful (0 votes)
3 views

UNIT 3 Programming Concepts

This document covers programming concepts, focusing on environment setup, language levels, and the C programming language. It explains the transition from machine language to assembly and higher-level languages, detailing the roles of compilers and interpreters. Additionally, it discusses C character sets, tokens, keywords, variables, and data types, providing essential rules and examples for each concept.

Uploaded by

vaibhavsarvaiya5
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

UNIT 3 Programming Concepts

This document covers programming concepts, focusing on environment setup, language levels, and the C programming language. It explains the transition from machine language to assembly and higher-level languages, detailing the roles of compilers and interpreters. Additionally, it discusses C character sets, tokens, keywords, variables, and data types, providing essential rules and examples for each concept.

Uploaded by

vaibhavsarvaiya5
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

UNIT 3 PROGRAMMING CONCEPTS

#Environment Setup
Link for downloading VS code
https://www.youtube.com/watch?v=JGsyJI8XG0Y

Link to download MinGW


https://www.youtube.com/watch?v=hAnTiNm7mUE

Link to to Set up Visual Studio Code for C and C++ Programming


https://www.youtube.com/watch?v=77v-Poud_io

# 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.

Interpreter: It is a program that directly executes the instructions in a high-


level language, without converting it into machine code. In programming, we
can execute a program in two ways. Firstly, through compilation and secondly,
through an interpreter.

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.

Every C program contains statements. These statements are constructed using


words and these words are constructed using characters from C character set. C
language character set contains the following set of 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.

In a c program tokens may contain the following...

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.

In the C programming language, there are 32 keywords. All the 32 keywords


have their meaning which is already known to the compiler.
Whenever C compiler come across a keyword, automatically it understands its
meaning.

Properties of Keywords

1. All the keywords in C programming language are defined as lowercase


letters so they must be used only in lowercase letters
2. Every keyword has a specific meaning, users can not change that
meaning.
3. Keywords can not be used as user-defined names like variable, functions,
arrays, pointers, etc...
4. Every keyword in C programming language represents something or
specifies some kind of action to be performed by the compiler.

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.

A variable name may contain letters, digits and underscore symbol.


The following are the rules to specify a variable name...

1. Variable name should not start with a digit.


2. Keywords should not be used as variable names.
3. A variable name should not contain any special symbols except
underscore(_).
4. A variable name can be of any length but compiler considers only the
first 31 characters of the variable name.

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...

1. Primary data types (Basic data types OR Predefined data types)


2. Derived data types (Secondary data types OR User-defined data types)
3. Enumeration data types
4. Void data type
Integer Data types:
Floating Point data types
Floating-point data types are a set of numbers with the decimal value. Every
floating-point value must contain the decimal value. The floating-point data
type has two variants...

 float
 double

Character data type


The character data type is a set of characters enclosed in single quotations. The
following table provides complete details about the character data type.

You might also like