SlideShare a Scribd company logo
1 of 48
Download to read offline
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
PAPER NAME: PROGRAMMING IN C
PAPER CODE: BCA 105
CLASS: BCA Ist Semester
UNIT-I Data Types
Data Transformation
 Programs transform data from one form to another
◦ Input data → Output data
◦ Stimulus → Response
 Programming languages store and process data in various ways depending on
the type of the data; consequently, all data read, processed, or written by a
program must have a type
 Two distinguishing characteristics of a programming language are the data
types it supports and the operations on those data types
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
A Data Type
• A data type is
– A set of values AND
– A set of operations on those values
• A data type is used to
– Identify the type of a variable when the variable is declared
– Identify the type of the return value of a function
– Identify the type of a parameter expected by a function
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
A Data Type (continued)
• When the compiler encounters a declaration for a variable, it sets up a memory
location for it
• An operator used on a variable or variables is legal only if
– The operator is defined in that programming language for a variable of that
type
– The variable or variables involved with the operator are of the same or
compatible types
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Rules for Constructing Identifiers
 Capital letters A-Z, lowercase letters a-z, digits 0-9, and the underscore
character
 First character must be a letter or underscore
 Usually only the first 32 characters are significant
 There can be no embedded blanks
 Keywords cannot be used as identifiers
 Identifiers are case sensitive
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Two Classifications of Data Types
• Built-in data types
– Fundamental data types (int, char, double, float, void, pointer)
– Derived data types (array, string, structure)
• Programmer-defined data types
– Structure
– Union
– Enumeration
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Basic Data Types
• Integral Types
– Integers are stored in various sizes. They can be signed or unsigned.
– Example
Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign
bit. If the sign bit is 0, the number is treated as positive.
Bit pattern 01001011 = 75 (decimal).
The largest positive number is 01111111 = 27 – 1 = 127.
Negative numbers are stored as two’s complement or as one’s
complement.
-75 = 10110100 (one’s complement).
-75 = 10110101 (two’s complement).
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
8
Basic Data Types
• Integral Types
– char Stored as 8 bits. Unsigned 0 to 255.
Signed -128 to 127.
– short int Stored as 16 bits. Unsigned 0 to 65535.
Signed -32768 to 32767.
– int Same as either short or long int.
– long int Stored as 32 bits. Unsigned 0 to 4294967295.
Signed -2147483648 to 2147483647
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Basic Data Types
• Floating Point Numbers
– Floating point numbers are rational numbers. Always signed numbers.
– float Approximate precision of 6 decimal digits .
• Typically stored in 4 bytes with 24 bits of signed mantissa and 8
bits of signed exponent.
– double Approximate precision of 14 decimal digits.
• Typically stored in 8 bytes with 56 bits of signed mantissa and 8
bits of signed exponent.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Constants
• Numerical Constants
– Constants like 12, 253 are stored as int type. No decimal point.
– 12L or 12l are stored as long int.
– 12U or 12u are stored as unsigned int.
– 12UL or 12ul are stored as unsigned long int.
– Numbers with a decimal point (12.34) are stored as double.
– Numbers with exponent (12e-3 = 12 x 10-3 ) are stored as double.
– 12.34f or 1.234e1f are stored as float.
– These are not valid constants:
25,000 7.1e 4 $200 2.3e-3.4 etc.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Constants
• Character and string constants
– ‘c’ , a single character in single quotes are stored as char.
Some special character are represented as two characters in single
quotes.
‘n’ = newline, ‘t’= tab, ‘’ = backlash, ‘”’ = double quotes.
Char constants also can be written in terms of their ASCII code.
‘060’ = ‘0’ (Decimal code is 48).
– A sequence of characters enclosed in double quotes is called a string
constant or string literal. For example
“Charu”
“A”
“3/9”
“x = 5”
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Variables
• Naming a Variable
– Must be a valid identifier.
– Must not be a keyword
– Names are case sensitive.
– Variables are identified by only first 32 characters.
– Library commonly uses names beginning with _.
– Naming Styles: Uppercase style and Underscore style
– lowerLimit lower_limit
– incomeTax income_tax
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Declarations
• Declaring a Variable
– Each variable used must be declared.
– A form of a declaration statement is
data-type var1, var2,…;
– Declaration announces the data type of a variable and allocates
appropriate memory location. No initial value (like 0 for integers)
should be assumed.
– It is possible to assign an initial value to a variable in the declaration
itself.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Derived Data Types
• Array – a finite sequence (or table) of variables of the same data type
• String – an array of character variables
• Structure – a collection of related variables of the same and/or
different data types. The structure is called a record and the variables
in the record are called members or fields
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Derived Data Types
• Array – a finite sequence (or table) of variables of the same data type
• String – an array of character variables
• Structure – a collection of related variables of the same and/or
different data types. The structure is called a record and the variables
in the record are called members or fields
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
UNIT-II Arrays
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
• An array is a collection of data elements that are of the same type (e.g.,
a collection of integers, collection of characters, collection of doubles).
Arrays
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
• 1-dimensional array.
• 3-dimensional array (3rd dimension is the day).
Array Applications
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
• Given a list of test scores, determine the maximum and minimum scores.
• Read in a list of student names and rearrange them in alphabetical order (sorting).
• Given the height measurements of students in a class, output the names of those
students who are taller than average.
Array Declaration
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
• Syntax:
<type> <arrayName>[<array_size>]
Ex. int Ar[10];
• The array elements are all values of the type <type>.
• The size of the array is indicated by <array_size>, the
number of elements in the array.
• <array_size> must be an int constant or a constant
expression. Note that an array can have multiple dimensions.
Array Declaration
// array of 10 uninitialized ints
int Ar[10];
-- -- ----Ar -- -- ---- -- --
4 5 630 2 8 971
0 1 2 3 4 5
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Subscripting
• Declare an array of 10 integers:
int Ar[10]; // array of 10 ints
• To access an individual element we must apply a subscript
to array named Ar.
– A subscript is a bracketed expression.
• The expression in the brackets is known as the index.
– First element of array has index 0.
Ar[0]
– Second element of array has index 1, and so on.
Ar[1], Ar[2], Ar[3],…
– Last element has an index one less than the size of the array.
Ar[9]
• Incorrect indexing is a common error.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Subscripting
// array of 10 uninitialized ints
int Ar[10];
Ar[3] = 1;
int x = Ar[3];
-- -- 1--Ar -- -- ---- -- --
4 5 630 2 8 971
Ar[4] Ar[5] Ar[6]Ar[3]Ar[0] Ar[2] Ar[8] Ar[9]Ar[7]Ar[1]
1
-- -- --
--
--
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Initializing arrays with random values
The following loop initializes the array myList with random values
between 0 and 99:
for (int i = 0; i < ARRAY_SIZE; i++)
{
myList[i] = rand() % 100;
}
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Semester: FIRST Semester
Name of the Subject:
Programming in C Language
STRUCTURS & UNIONS
UNIT-III Structures
•Compound data:
•A date is
– an int month and
– an int day and
– an int year
•Unlike Java, C doesn’t automatically
define functions for initializing and
printing …
struct ADate {
int month;
int day;
int year;
};
struct ADate date;
date.month = 1;
date.day = 18;
date.year = 2018;
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
26
Typedef
• Mechanism for creating new type names
– New names are an alias for some other type
– May improve clarity and/or portability of the program
typedef long int64_t;
typedef struct ADate {
int month;
int day;
int year;
} Date;
int64_t i = 100000000000;
Date d = { 1, 18, 2018 };
Overload existing type
names for clarity and
portability
Simplify complex type
names
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Constants
• Allow consistent use of the same constant throughout the program
– Improves clarity of the program
– Reduces likelihood of simple errors
– Easier to update constants in the program
int array[10];
for (i=0; i<10;
i++) {
…
}
#define SIZE 10
int array[SIZE];
for (i=0;
i<SIZE; i++) {
…
}
Preprocess
or
directive
Constant names are
capitalized by convention
Define once,
use throughout
the program
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Structure Representation & Size
•sizeof(struct …) =
• sum of sizeof(field)
•+ alignment padding
Processor- and compiler-specific
6261 EF BE AD DE
c1 c2 ipadding
struct CharCharInt {
char c1;
char c2;
int i;
} foo;
foo.c1 = ’a’;
foo.c2 = ’b’;
foo.i = 0xDEADBEEF;
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Arrays of Structures
Date birthdays[NFRIENDS];
bool
check_birthday(Date today)
{
int i;
for (i = 0; i < NFRIENDS; i++) {
if ((today.month == birthdays[i].month) &&
(today.day == birthdays[i].day))
return (true);
return (false);
}
ConstantArray declaration
Array index, then
structure field
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Pointers to Structures
Date
create_date1(int month,
int day,
int year)
{
Date d;
d.month = month;
d.day = day;
d.year = year;
return (d);
}
void
create_date2(Date *d,
int month,
int day,
int year)
{
d->month = month;
d->day = day;
d->year = year;
}
Copies date
Pass-by-reference
Date today;
today = create_date1(1, 18, 2018);
create_date2(&today, 1, 18, 2018);
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Pointers to Structures (cont.)
void
create_date2(Date *d,
int month,
int day,
int year)
{
d->month = month;
d->day = day;
d->year = year;
}
void
fun_with_dates(void)
{
Date today;
create_date2(&today, 1, 18, 2018);
}
today.month:
today.day:
today.year:
0x1000
0x1004
0x1008
month: 1
day: 18
year: 2018
0x30A0
0x30A4
0x30A8
d: 0x10000x3098
1
18
2018
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Pointers to Structures (cont.)
void
create_date2(Date *d,
int month,
int day,
int year)
{
d->month = month;
d->day = day;
d->year = year;
}
void
fun_with_dates(void)
{
Date today;
create_date2(&today, 1, 18, 2018);
}
today.month:
today.day:
today.year:
0x1000
0x1004
0x1008
month: 1
day: 18
year: 2018
0x30A0
0x30A4
0x30A8
d: 0x10000x3098
1
18
2018
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Pointers to Structures (cont.)
Date *
create_date3(int month,
int day,
int year)
{
Date *d;
d->month = month;
d->day = day;
d->year = year;
return (d);
}
What is d pointing to?!?!
(more on this later)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Unions
•Choices:
•An element is
– an int i or
– a char c
•sizeof(union …) =
maximum of sizeof(field)
EF BE AD DE
c
i
padding
union AnElt {
int i;
char c;
} elt1, elt2;
elt1.i = 4;
elt2.c = ’a’;
elt2.i = 0xDEADBEEF;
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Unions
• A union value doesn’t “know” which case it contains
union AnElt {
int i;
char c;
} elt1, elt2;
elt1.i = 4;
elt2.c = ’a’;
elt2.i = 0xDEADBEEF;
if (elt1 currently has a char) …
How should your program keep track
whether elt1, elt2 hold an int or
a char?
?
?
Basic answer: Another variable holds
that info
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Tagged Unions
• Tag every value with its case
• I.e., pair the type info together with the union
• Implicit in Java, Scheme, ML, …
Enum must be external to struct,
so constants are globally visible.
Struct field must be named.
enum Union_Tag { IS_INT, IS_CHAR };
struct TaggedUnion {
enum Union_Tag tag;
union {
int i;
char c;
} data;
};
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
UNIT-IV Strings
• C implements the string data structure using arrays of type char.
• You have already used the string extensively.
– printf(“This program is terminated!n”);
– #define ERR_Message “Error!!”
• Since string is an array, the declaration of a string is the same as declaring a
char array.
– char string_var[30];
– char string_var[20] = “Initial value”;
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Memory Storage for a String
• The string is always ended with a null character ‘0’.
• The characters after the null character are ignored.
• e.g., char str[20] = “Initial value”;
n i t i a l v a l u e ? ? …I 0
[0] [13]
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Arrays of Strings
• An array of strings is a two-dimensional array of characters in which each
row is one string.
– char names[People][Length];
– char month[5][10] = {“January”, “February”, “March”, “April”,
“May”};
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Input/Output of a String
• The placeholder %s is used to represent string arguments in printf and scanf.
– printf(“Topic: %sn”, string_var);
• The string can be right-justified by placing a positive number in the
placeholder.
– printf(“%8s”, str);
• The string can be left-justified by placing a negative number in the
placeholder.
– Printf(“%-8s”, str);
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Right and Left Justification of Strings
The “%8s” placeholder displays a string which is right-justified and in 8-
columns width.
If the actual string is longer than the width, the displayed field is expanded
with no padding.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Execution of scanf ("%s", dept);
• Whenever encountering a white space, the scanning stops and scanf
places the null character at the end of the string.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
String Library Functions
• The string can not be copied by the assignment operator ‘=’.
– e..g, “str = “Test String”” is not valid.
• C provides string manipulating functions in the “string.h” library.
– The complete list of these functions can be found in Appendix B of the
textbook.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Some String Functions from String.h
Function Purpose Example
strcpy Makes a copy of a string strcpy(s1, “Hi”);
strcat Appends a string to the end of
another string
strcat(s1, “more”);
strcmp Compare two strings alphabetically strcmp(s1, “Hu”);
strlen Returns the number of characters in
a string
strlen(“Hi”) returns 2.
strtok Breaks a string into tokens by
delimiters.
strtok(“Hi, Chao”, “ ,”);
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Functions strcpy and strncpy
• Function strcpy copies the string in the second argument into the first
argument.
– e.g., strcpy(dest, “test string”);
– The null character is appended at the end automatically.
– If source string is longer than the destination string, the overflow
characters may occupy the memory space used by other variables.
• Function strncpy copies the string by specifying the number of characters to
copy.
– You have to place the null character manually.
– e.g., strncpy(dest, “test string”, 6); dest[6] = ‘0’;
– If source string is longer than the destination string, the overflow
characters are discarded automatically.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Functions strcat and strlen
• Functions strcat and strncat concatenate the fist string argument with the
second string argument.
– strcat(dest, “more..”);
– strncat(dest, “more..”, 3);
• Function strlen is often used to check the length of a string (i.e., the number of
characters before the fist null character).
– e.g., dest[6] = “Hello”;
strncat(dest, “more”, 5-strlen(dest));
dest[5] = ‘0’;
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Input/Output of Characters and Strings
• The stdio library provides getchar function which gets the next character from
the standard input.
– “ch = getchar();” is the same as “scanf(“%c”, &ch);”
– Similar functions are putchar, gets, puts.
• For IO from/to the file, the stdio library also provides corresponding functions.
– getc: reads a character from a file.
– Similar functions are putc, fgets, fputs.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
The sprintf and sscanf Functions
• The sprintf function substitutes values for placeholders just as printf does
except that it stores the result into a character array
– sprintf(s, “%d%d%d”, mon, day, year);
• The sscanf function works exactly like scanf except that it takes data from the
string as its input argument.
– sscanf(“ 11 22.2 Hello”, “%d%lf%s”, &num, &val, word);
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

More Related Content

Similar to PROGRAMMING IN C

OPPS using C++
OPPS using C++ OPPS using C++
OPPS using C++ cpjcollege
 
Business Economics
Business EconomicsBusiness Economics
Business Economicscpjcollege
 
Business Economics
Business EconomicsBusiness Economics
Business Economicscpjcollege
 
Financial Modelling With Spreadsheets
Financial Modelling With Spreadsheets Financial Modelling With Spreadsheets
Financial Modelling With Spreadsheets cpjcollege
 
Digital electronics
Digital electronicsDigital electronics
Digital electronicscpjcollege
 
Object oriented programming using BCA 209
Object oriented programming using BCA 209Object oriented programming using BCA 209
Object oriented programming using BCA 209cpjcollege
 
Trade union act 1926
Trade union act 1926Trade union act 1926
Trade union act 1926cpjcollege
 
Technical communication
Technical communicationTechnical communication
Technical communicationcpjcollege
 
Organizational behavior
Organizational behavior Organizational behavior
Organizational behavior cpjcollege
 
Organisational Behaviour
Organisational BehaviourOrganisational Behaviour
Organisational Behaviourcpjcollege
 
Management & Cost Accounting
Management & Cost AccountingManagement & Cost Accounting
Management & Cost Accountingcpjcollege
 
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )cpjcollege
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecturecpjcollege
 
Organization Behavior
Organization BehaviorOrganization Behavior
Organization Behaviorcpjcollege
 
Managerial Personality Development
Managerial Personality DevelopmentManagerial Personality Development
Managerial Personality Developmentcpjcollege
 
Business Economics
Business EconomicsBusiness Economics
Business Economicscpjcollege
 
Management Information System
Management Information SystemManagement Information System
Management Information Systemcpjcollege
 
Management Information system
Management Information systemManagement Information system
Management Information systemcpjcollege
 

Similar to PROGRAMMING IN C (20)

Normalization
NormalizationNormalization
Normalization
 
OPPS using C++
OPPS using C++ OPPS using C++
OPPS using C++
 
Business Economics
Business EconomicsBusiness Economics
Business Economics
 
Business Economics
Business EconomicsBusiness Economics
Business Economics
 
Financial Modelling With Spreadsheets
Financial Modelling With Spreadsheets Financial Modelling With Spreadsheets
Financial Modelling With Spreadsheets
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
Object oriented programming using BCA 209
Object oriented programming using BCA 209Object oriented programming using BCA 209
Object oriented programming using BCA 209
 
Trade union act 1926
Trade union act 1926Trade union act 1926
Trade union act 1926
 
Technical communication
Technical communicationTechnical communication
Technical communication
 
Organizational behavior
Organizational behavior Organizational behavior
Organizational behavior
 
Organisational Behaviour
Organisational BehaviourOrganisational Behaviour
Organisational Behaviour
 
PDCS II
PDCS IIPDCS II
PDCS II
 
Management & Cost Accounting
Management & Cost AccountingManagement & Cost Accounting
Management & Cost Accounting
 
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Organization Behavior
Organization BehaviorOrganization Behavior
Organization Behavior
 
Managerial Personality Development
Managerial Personality DevelopmentManagerial Personality Development
Managerial Personality Development
 
Business Economics
Business EconomicsBusiness Economics
Business Economics
 
Management Information System
Management Information SystemManagement Information System
Management Information System
 
Management Information system
Management Information systemManagement Information system
Management Information system
 

More from cpjcollege

Tax Law (LLB-403)
Tax Law (LLB-403)Tax Law (LLB-403)
Tax Law (LLB-403)cpjcollege
 
Law and Emerging Technology (LLB -405)
 Law and Emerging Technology (LLB -405) Law and Emerging Technology (LLB -405)
Law and Emerging Technology (LLB -405)cpjcollege
 
Law of Crimes-I ( LLB -205)
 Law of Crimes-I  ( LLB -205)  Law of Crimes-I  ( LLB -205)
Law of Crimes-I ( LLB -205) cpjcollege
 
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )cpjcollege
 
Family Law-I ( LLB -201)
Family Law-I  ( LLB -201) Family Law-I  ( LLB -201)
Family Law-I ( LLB -201) cpjcollege
 
Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] cpjcollege
 
Law of Evidence (LLB-303)
Law of Evidence  (LLB-303) Law of Evidence  (LLB-303)
Law of Evidence (LLB-303) cpjcollege
 
Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)cpjcollege
 
Code of Civil Procedure (LLB -307)
 Code of Civil Procedure (LLB -307) Code of Civil Procedure (LLB -307)
Code of Civil Procedure (LLB -307)cpjcollege
 
Constitutional Law-I (LLB -203)
 Constitutional Law-I (LLB -203) Constitutional Law-I (LLB -203)
Constitutional Law-I (LLB -203)cpjcollege
 
Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]cpjcollege
 
Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)cpjcollege
 
Human Rights Law ( LLB -407)
 Human Rights Law ( LLB -407) Human Rights Law ( LLB -407)
Human Rights Law ( LLB -407)cpjcollege
 
Labour Law-I (LLB 401)
 Labour Law-I (LLB 401) Labour Law-I (LLB 401)
Labour Law-I (LLB 401)cpjcollege
 
Legal Ethics and Court Craft (LLB 501)
 Legal Ethics and Court Craft (LLB 501) Legal Ethics and Court Craft (LLB 501)
Legal Ethics and Court Craft (LLB 501)cpjcollege
 
Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)cpjcollege
 
Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )cpjcollege
 
Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)cpjcollege
 
Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )cpjcollege
 
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 ) PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 )
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )cpjcollege
 

More from cpjcollege (20)

Tax Law (LLB-403)
Tax Law (LLB-403)Tax Law (LLB-403)
Tax Law (LLB-403)
 
Law and Emerging Technology (LLB -405)
 Law and Emerging Technology (LLB -405) Law and Emerging Technology (LLB -405)
Law and Emerging Technology (LLB -405)
 
Law of Crimes-I ( LLB -205)
 Law of Crimes-I  ( LLB -205)  Law of Crimes-I  ( LLB -205)
Law of Crimes-I ( LLB -205)
 
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
 
Family Law-I ( LLB -201)
Family Law-I  ( LLB -201) Family Law-I  ( LLB -201)
Family Law-I ( LLB -201)
 
Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309]
 
Law of Evidence (LLB-303)
Law of Evidence  (LLB-303) Law of Evidence  (LLB-303)
Law of Evidence (LLB-303)
 
Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)
 
Code of Civil Procedure (LLB -307)
 Code of Civil Procedure (LLB -307) Code of Civil Procedure (LLB -307)
Code of Civil Procedure (LLB -307)
 
Constitutional Law-I (LLB -203)
 Constitutional Law-I (LLB -203) Constitutional Law-I (LLB -203)
Constitutional Law-I (LLB -203)
 
Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]
 
Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)
 
Human Rights Law ( LLB -407)
 Human Rights Law ( LLB -407) Human Rights Law ( LLB -407)
Human Rights Law ( LLB -407)
 
Labour Law-I (LLB 401)
 Labour Law-I (LLB 401) Labour Law-I (LLB 401)
Labour Law-I (LLB 401)
 
Legal Ethics and Court Craft (LLB 501)
 Legal Ethics and Court Craft (LLB 501) Legal Ethics and Court Craft (LLB 501)
Legal Ethics and Court Craft (LLB 501)
 
Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)
 
Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )
 
Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)
 
Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )
 
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 ) PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 )
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 

Recently uploaded

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

PROGRAMMING IN C

  • 1. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) PAPER NAME: PROGRAMMING IN C PAPER CODE: BCA 105 CLASS: BCA Ist Semester
  • 2. UNIT-I Data Types Data Transformation  Programs transform data from one form to another ◦ Input data → Output data ◦ Stimulus → Response  Programming languages store and process data in various ways depending on the type of the data; consequently, all data read, processed, or written by a program must have a type  Two distinguishing characteristics of a programming language are the data types it supports and the operations on those data types Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 3. A Data Type • A data type is – A set of values AND – A set of operations on those values • A data type is used to – Identify the type of a variable when the variable is declared – Identify the type of the return value of a function – Identify the type of a parameter expected by a function Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 4. A Data Type (continued) • When the compiler encounters a declaration for a variable, it sets up a memory location for it • An operator used on a variable or variables is legal only if – The operator is defined in that programming language for a variable of that type – The variable or variables involved with the operator are of the same or compatible types Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 5. Rules for Constructing Identifiers  Capital letters A-Z, lowercase letters a-z, digits 0-9, and the underscore character  First character must be a letter or underscore  Usually only the first 32 characters are significant  There can be no embedded blanks  Keywords cannot be used as identifiers  Identifiers are case sensitive Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 6. Two Classifications of Data Types • Built-in data types – Fundamental data types (int, char, double, float, void, pointer) – Derived data types (array, string, structure) • Programmer-defined data types – Structure – Union – Enumeration Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 7. Basic Data Types • Integral Types – Integers are stored in various sizes. They can be signed or unsigned. – Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign bit is 0, the number is treated as positive. Bit pattern 01001011 = 75 (decimal). The largest positive number is 01111111 = 27 – 1 = 127. Negative numbers are stored as two’s complement or as one’s complement. -75 = 10110100 (one’s complement). -75 = 10110101 (two’s complement). Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 8. 8 Basic Data Types • Integral Types – char Stored as 8 bits. Unsigned 0 to 255. Signed -128 to 127. – short int Stored as 16 bits. Unsigned 0 to 65535. Signed -32768 to 32767. – int Same as either short or long int. – long int Stored as 32 bits. Unsigned 0 to 4294967295. Signed -2147483648 to 2147483647 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 9. Basic Data Types • Floating Point Numbers – Floating point numbers are rational numbers. Always signed numbers. – float Approximate precision of 6 decimal digits . • Typically stored in 4 bytes with 24 bits of signed mantissa and 8 bits of signed exponent. – double Approximate precision of 14 decimal digits. • Typically stored in 8 bytes with 56 bits of signed mantissa and 8 bits of signed exponent. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 10. Constants • Numerical Constants – Constants like 12, 253 are stored as int type. No decimal point. – 12L or 12l are stored as long int. – 12U or 12u are stored as unsigned int. – 12UL or 12ul are stored as unsigned long int. – Numbers with a decimal point (12.34) are stored as double. – Numbers with exponent (12e-3 = 12 x 10-3 ) are stored as double. – 12.34f or 1.234e1f are stored as float. – These are not valid constants: 25,000 7.1e 4 $200 2.3e-3.4 etc. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 11. Constants • Character and string constants – ‘c’ , a single character in single quotes are stored as char. Some special character are represented as two characters in single quotes. ‘n’ = newline, ‘t’= tab, ‘’ = backlash, ‘”’ = double quotes. Char constants also can be written in terms of their ASCII code. ‘060’ = ‘0’ (Decimal code is 48). – A sequence of characters enclosed in double quotes is called a string constant or string literal. For example “Charu” “A” “3/9” “x = 5” Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 12. Variables • Naming a Variable – Must be a valid identifier. – Must not be a keyword – Names are case sensitive. – Variables are identified by only first 32 characters. – Library commonly uses names beginning with _. – Naming Styles: Uppercase style and Underscore style – lowerLimit lower_limit – incomeTax income_tax Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 13. Declarations • Declaring a Variable – Each variable used must be declared. – A form of a declaration statement is data-type var1, var2,…; – Declaration announces the data type of a variable and allocates appropriate memory location. No initial value (like 0 for integers) should be assumed. – It is possible to assign an initial value to a variable in the declaration itself. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 14. Derived Data Types • Array – a finite sequence (or table) of variables of the same data type • String – an array of character variables • Structure – a collection of related variables of the same and/or different data types. The structure is called a record and the variables in the record are called members or fields Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 15. Derived Data Types • Array – a finite sequence (or table) of variables of the same data type • String – an array of character variables • Structure – a collection of related variables of the same and/or different data types. The structure is called a record and the variables in the record are called members or fields Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 16. UNIT-II Arrays Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) • An array is a collection of data elements that are of the same type (e.g., a collection of integers, collection of characters, collection of doubles).
  • 17. Arrays Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) • 1-dimensional array. • 3-dimensional array (3rd dimension is the day).
  • 18. Array Applications Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) • Given a list of test scores, determine the maximum and minimum scores. • Read in a list of student names and rearrange them in alphabetical order (sorting). • Given the height measurements of students in a class, output the names of those students who are taller than average.
  • 19. Array Declaration Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) • Syntax: <type> <arrayName>[<array_size>] Ex. int Ar[10]; • The array elements are all values of the type <type>. • The size of the array is indicated by <array_size>, the number of elements in the array. • <array_size> must be an int constant or a constant expression. Note that an array can have multiple dimensions.
  • 20. Array Declaration // array of 10 uninitialized ints int Ar[10]; -- -- ----Ar -- -- ---- -- -- 4 5 630 2 8 971 0 1 2 3 4 5 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 21. Subscripting • Declare an array of 10 integers: int Ar[10]; // array of 10 ints • To access an individual element we must apply a subscript to array named Ar. – A subscript is a bracketed expression. • The expression in the brackets is known as the index. – First element of array has index 0. Ar[0] – Second element of array has index 1, and so on. Ar[1], Ar[2], Ar[3],… – Last element has an index one less than the size of the array. Ar[9] • Incorrect indexing is a common error. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 22. Subscripting // array of 10 uninitialized ints int Ar[10]; Ar[3] = 1; int x = Ar[3]; -- -- 1--Ar -- -- ---- -- -- 4 5 630 2 8 971 Ar[4] Ar[5] Ar[6]Ar[3]Ar[0] Ar[2] Ar[8] Ar[9]Ar[7]Ar[1] 1 -- -- -- -- -- Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 23. Initializing arrays with random values The following loop initializes the array myList with random values between 0 and 99: for (int i = 0; i < ARRAY_SIZE; i++) { myList[i] = rand() % 100; } Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 24. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) Semester: FIRST Semester Name of the Subject: Programming in C Language STRUCTURS & UNIONS
  • 25. UNIT-III Structures •Compound data: •A date is – an int month and – an int day and – an int year •Unlike Java, C doesn’t automatically define functions for initializing and printing … struct ADate { int month; int day; int year; }; struct ADate date; date.month = 1; date.day = 18; date.year = 2018; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 26. 26 Typedef • Mechanism for creating new type names – New names are an alias for some other type – May improve clarity and/or portability of the program typedef long int64_t; typedef struct ADate { int month; int day; int year; } Date; int64_t i = 100000000000; Date d = { 1, 18, 2018 }; Overload existing type names for clarity and portability Simplify complex type names Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 27. Constants • Allow consistent use of the same constant throughout the program – Improves clarity of the program – Reduces likelihood of simple errors – Easier to update constants in the program int array[10]; for (i=0; i<10; i++) { … } #define SIZE 10 int array[SIZE]; for (i=0; i<SIZE; i++) { … } Preprocess or directive Constant names are capitalized by convention Define once, use throughout the program Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 28. Structure Representation & Size •sizeof(struct …) = • sum of sizeof(field) •+ alignment padding Processor- and compiler-specific 6261 EF BE AD DE c1 c2 ipadding struct CharCharInt { char c1; char c2; int i; } foo; foo.c1 = ’a’; foo.c2 = ’b’; foo.i = 0xDEADBEEF; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 29. Arrays of Structures Date birthdays[NFRIENDS]; bool check_birthday(Date today) { int i; for (i = 0; i < NFRIENDS; i++) { if ((today.month == birthdays[i].month) && (today.day == birthdays[i].day)) return (true); return (false); } ConstantArray declaration Array index, then structure field Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 30. Pointers to Structures Date create_date1(int month, int day, int year) { Date d; d.month = month; d.day = day; d.year = year; return (d); } void create_date2(Date *d, int month, int day, int year) { d->month = month; d->day = day; d->year = year; } Copies date Pass-by-reference Date today; today = create_date1(1, 18, 2018); create_date2(&today, 1, 18, 2018); Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 31. Pointers to Structures (cont.) void create_date2(Date *d, int month, int day, int year) { d->month = month; d->day = day; d->year = year; } void fun_with_dates(void) { Date today; create_date2(&today, 1, 18, 2018); } today.month: today.day: today.year: 0x1000 0x1004 0x1008 month: 1 day: 18 year: 2018 0x30A0 0x30A4 0x30A8 d: 0x10000x3098 1 18 2018 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 32. Pointers to Structures (cont.) void create_date2(Date *d, int month, int day, int year) { d->month = month; d->day = day; d->year = year; } void fun_with_dates(void) { Date today; create_date2(&today, 1, 18, 2018); } today.month: today.day: today.year: 0x1000 0x1004 0x1008 month: 1 day: 18 year: 2018 0x30A0 0x30A4 0x30A8 d: 0x10000x3098 1 18 2018 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 33. Pointers to Structures (cont.) Date * create_date3(int month, int day, int year) { Date *d; d->month = month; d->day = day; d->year = year; return (d); } What is d pointing to?!?! (more on this later) Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 34. Unions •Choices: •An element is – an int i or – a char c •sizeof(union …) = maximum of sizeof(field) EF BE AD DE c i padding union AnElt { int i; char c; } elt1, elt2; elt1.i = 4; elt2.c = ’a’; elt2.i = 0xDEADBEEF; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 35. Unions • A union value doesn’t “know” which case it contains union AnElt { int i; char c; } elt1, elt2; elt1.i = 4; elt2.c = ’a’; elt2.i = 0xDEADBEEF; if (elt1 currently has a char) … How should your program keep track whether elt1, elt2 hold an int or a char? ? ? Basic answer: Another variable holds that info Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 36. Tagged Unions • Tag every value with its case • I.e., pair the type info together with the union • Implicit in Java, Scheme, ML, … Enum must be external to struct, so constants are globally visible. Struct field must be named. enum Union_Tag { IS_INT, IS_CHAR }; struct TaggedUnion { enum Union_Tag tag; union { int i; char c; } data; }; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 37. UNIT-IV Strings • C implements the string data structure using arrays of type char. • You have already used the string extensively. – printf(“This program is terminated!n”); – #define ERR_Message “Error!!” • Since string is an array, the declaration of a string is the same as declaring a char array. – char string_var[30]; – char string_var[20] = “Initial value”; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 38. Memory Storage for a String • The string is always ended with a null character ‘0’. • The characters after the null character are ignored. • e.g., char str[20] = “Initial value”; n i t i a l v a l u e ? ? …I 0 [0] [13] Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 39. Arrays of Strings • An array of strings is a two-dimensional array of characters in which each row is one string. – char names[People][Length]; – char month[5][10] = {“January”, “February”, “March”, “April”, “May”}; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 40. Input/Output of a String • The placeholder %s is used to represent string arguments in printf and scanf. – printf(“Topic: %sn”, string_var); • The string can be right-justified by placing a positive number in the placeholder. – printf(“%8s”, str); • The string can be left-justified by placing a negative number in the placeholder. – Printf(“%-8s”, str); Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 41. Right and Left Justification of Strings The “%8s” placeholder displays a string which is right-justified and in 8- columns width. If the actual string is longer than the width, the displayed field is expanded with no padding. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 42. Execution of scanf ("%s", dept); • Whenever encountering a white space, the scanning stops and scanf places the null character at the end of the string. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 43. String Library Functions • The string can not be copied by the assignment operator ‘=’. – e..g, “str = “Test String”” is not valid. • C provides string manipulating functions in the “string.h” library. – The complete list of these functions can be found in Appendix B of the textbook. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 44. Some String Functions from String.h Function Purpose Example strcpy Makes a copy of a string strcpy(s1, “Hi”); strcat Appends a string to the end of another string strcat(s1, “more”); strcmp Compare two strings alphabetically strcmp(s1, “Hu”); strlen Returns the number of characters in a string strlen(“Hi”) returns 2. strtok Breaks a string into tokens by delimiters. strtok(“Hi, Chao”, “ ,”); Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 45. Functions strcpy and strncpy • Function strcpy copies the string in the second argument into the first argument. – e.g., strcpy(dest, “test string”); – The null character is appended at the end automatically. – If source string is longer than the destination string, the overflow characters may occupy the memory space used by other variables. • Function strncpy copies the string by specifying the number of characters to copy. – You have to place the null character manually. – e.g., strncpy(dest, “test string”, 6); dest[6] = ‘0’; – If source string is longer than the destination string, the overflow characters are discarded automatically. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 46. Functions strcat and strlen • Functions strcat and strncat concatenate the fist string argument with the second string argument. – strcat(dest, “more..”); – strncat(dest, “more..”, 3); • Function strlen is often used to check the length of a string (i.e., the number of characters before the fist null character). – e.g., dest[6] = “Hello”; strncat(dest, “more”, 5-strlen(dest)); dest[5] = ‘0’; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 47. Input/Output of Characters and Strings • The stdio library provides getchar function which gets the next character from the standard input. – “ch = getchar();” is the same as “scanf(“%c”, &ch);” – Similar functions are putchar, gets, puts. • For IO from/to the file, the stdio library also provides corresponding functions. – getc: reads a character from a file. – Similar functions are putc, fgets, fputs. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
  • 48. The sprintf and sscanf Functions • The sprintf function substitutes values for placeholders just as printf does except that it stores the result into a character array – sprintf(s, “%d%d%d”, mon, day, year); • The sscanf function works exactly like scanf except that it takes data from the string as its input argument. – sscanf(“ 11 22.2 Hello”, “%d%lf%s”, &num, &val, word); Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)