FCP 1 DataComm+ProgC
FCP 1 DataComm+ProgC
COMPUTER AND
PROGRAMMING
Dr. Raghavendra Pal
Syllabus
Syllabus
Syllabus
Syllabus
Data Communication
◦The term telecommunication means communication at a distance.
The word data refers to information presented in whatever form is
agreed upon by the parties creating and using the data. Data
communications are the exchange of data between two devices via
some form of transmission medium such as a wire cable.
Transmission media
GUIDED MEDIA: Twisted Pair Cable
◦ Twisted pair cable is a type of wiring in which two
conductors of a single circuit are twisted together for the
purposes of improving electromagnetic compatibility.
The wires are twisted to cancel out electromagnetic
interference (EMI) from external sources and crosstalk
from adjacent pairs.
◦ Data is transmitted over the twisted pairs as electrical
signals.
Coaxial cable
◦ Coaxial cable, or coax, is a type of electrical cable consisting of a central conductor, an insulating layer, a
metallic shield, and an outer insulating layer.
◦ It is used for transmitting cable television signals, internet connections, and other data communications.
Optical Fiber
◦ Optical fiber is a flexible, transparent fiber made of high-quality glass (silica) or plastic, slightly thicker than a
human hair, that functions as a waveguide or light pipe to transmit light between the two ends of the fiber. It is
primarily used in telecommunications and networking, where it enables long-distance, high-speed data
transmission. Optical fibers operate on the principle of total internal reflection, allowing light to be guided through
the core of the fiber with minimal loss. This makes them highly effective for transmitting large amounts of data
over long distances with high fidelity and low attenuation.
UNGUIDED MEDIA: WIRELESS
Keywords are reserved words in C that have a special meaning and cannot be used as
identifiers.
Examples: int, return, while, for, if, else, float, char.
Characteristics:
All keywords are written in lowercase.
Keywords have predefined meanings in C and are part of the C language syntax.
Examples in Context:
int main() - Here, int is a keyword that specifies the return type of the function main.
return 0; - return is a keyword used to exit a function and optionally return a value.
Data Types in C
Basic Data Types:
int: Used for integers (whole numbers).
•Example: int age = 25;
float: Used for single-precision floating-point numbers (decimals).
•Example: float temperature = 36.6;
double: Used for double-precision floating-point numbers (decimals).
•Example: double pi = 3.14159;
char: Used for characters.
•Example: char grade = 'A';
Data Types in C
Derived Data Types
Array: Collection of elements of the same type.
•Example: int numbers[5] = {1, 2, 3, 4, 5};
Pointer: Stores the address of a variable.
•Example: int *ptr; ptr = &age;
Structure: Groups different data types into a single unit.
•Example: struct Student { int id; char name[50]; };
Union: Similar to a structure, but members share the same memory location.
•Example: union Data { int i; float f; char str[20]; };
Data Types in C
Enumeration (enum): A user-defined data type that assigns names to integral constants.
•Example: enum week {Sunday, Monday, Tuesday};
Constants in C
Constants are fixed values that cannot be altered by the program during execution.
•Types of Constants:
•Integer Constants: Whole numbers without any fractional part.
•Example: const int MAX_VALUE = 100;
•Floating-point Constants: Numbers with fractional parts.
•Example: const float PI = 3.14;
•Character Constants: Single characters enclosed in single quotes.
•Example: const char NEWLINE = '\n';
•String Constants: Sequence of characters enclosed in double quotes.
•Example: const char GREETING[] = "Hello";
•Example in Context:
•Usage: #define PI 3.14159
Variables in C
Definition: Variables are named memory locations used to store data that can be modified
during program execution.
Declaration and Initialization:
Example: int age = 21;
Naming Rules:
Must start with a letter or underscore.
Can contain letters, numbers, and underscores.
Cannot use C keywords as variable names.
Types:
Local Variables: Declared inside a function and can only be used within that function.
Global Variables: Declared outside of all functions and can be accessed by any function
within the program.
Static Variables: Retain their value between function calls.
Declarations in C
Definition: A declaration informs the compiler about the name and type of a variable,
function, or any other identifier
before it is used in the code.
Purpose: It tells the compiler how much memory to allocate and what type of data the
variable will hold.
1. Variable Declaration
Syntax: data_type variable_name;
Example:
Integer Declaration: int age;
Character Declaration: char grade;
Multiple Declarations: You can declare multiple variables of the same type in one line.
Example: int x, y, z;
Declarations in C
2. Function Declaration
Syntax: return_type function_name(parameter_list);
Example:
int add(int a, int b);
Declares a function add that takes two integers as parameters and returns an integer.
3. Array Declaration
Syntax: data_type array_name[array_size];
Example:
int numbers[10];
Declares an array of 10 integers.
Statements in C
2. Function Declaration
Syntax: return_type function_name(parameter_list);
Example:
int add(int a, int b);
Declares a function add that takes two integers as parameters and returns an integer.
3. Array Declaration
Syntax: data_type array_name[array_size];
Example:
int numbers[10];
Declares an array of 10 integers.