SlideShare a Scribd company logo
Dr. S. & S.S. Gandhy Government College of
Engineering and Technology
SEM:- 1ST
SUBJECT:- COMPUTER PROGRAMMING AND UTILIZATION
TOPIC:- ARRAY AND STRING
STUDENT’S NAME:-
PRATIK B. PATEL
PRASHANT A. CHELANI
VIJAY D. VADHER
NIKHIL R. PATIL
ARRAY :-
 NEED OF ARRAY
 ARRAY CONCEPT
 DECLARATION OF ONE-
DIMENTIONAL ARRAY
 INITIALIZATION OF ONE-
DIMENTIONAL ARRAY
 MULTYDIMENSIONAL ARRAY
NEED OF ARRAY:
 It is very difficult to write a
program in ‘C’ which consisting
large data items like addition of
50 integers, marks of student in
University, etc.
 ‘C’ program provides a solution
called ‘ARRAY’.
 By using array, it is easy to
include large numbers of data
items.
ARRAY CONCEPT:-
 An array is a group of data items of
the same data type that share a
common name.
 An array should be of same datatype
and consists of integers or strings and
so on.
 An array is linear and homogeneous.
 An array stores the data elements in
sequential order.
 Homogeneous means all data items
are of same datatype.
 Elements of array are specifying a
subscript.
 A subscript is also called index.
 Subscipt is start from 0 and cannot
negative.
 There are two types of array.
 1). One-dimentional arrays(also called
vectors)
 2). Multi-dimentional arrays(also called
Matrix)
DECLARATION OF ONE-
DIMENTIONAL ARRAY:-
 Syntex: datatype arrayname[size]
 Where,
 datatype:- The type of the data stored in the
array
 Arrayname:- Name of the array
 Size:- Maximum number of elements an array
can hold
 Example:- int marks[10]
Mark[0] Mark[1] ………….. ………..... Mark[9]
INITIALIZATIONOF ONE-DIMENTIONAL
ARRAY
 Int mark[6]={3,7,8,4,5,6}
 Is also equel to
 Int mark[]={3,7,8,4,5,6}
 It will occupy in memory like,
 a[0] a[1] a[2] a[3] a[4] a[5]
 Char a[8]={‘L’,’E’,’A’,’R’,’N’,’’,’C’}

 a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7]
 When compiler sees a character array, it add a null
character.So, while declaring a character array, we
must allow one extra element space for null character.
3 7 8 4 5 6
‘L’ ‘E’ ‘A’ ‘R’ ‘N’ ‘’ ‘C’ ‘0’
MULTYDIMENSIONAL ARRAY
 If an array have more than one dimension, is called
multi-dimensional array.
 Two dimensional array have two subscript, three
dimensional array have three subscript.
 Declaration of two dimensional array:-
 Int a[2][3]
 It consist of two rows and three colomns.
 a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2]
1 2 3 4 5 6
PROGRAMOF SIMPLE ARRAY
SOURCE CODE OUTPUT
Program to reverse a array
SOURCE CODE OUTPUT
Strings
 INTRODUCTION
 INITIALIZING STRING VARIABLES
 READING AND DISPLAYING STRINGS
 STRING HANDLING FUNCTIONS
 PROGRAMS OF STRING
INTRODUCTION :-
 Strings are array of characters i.e. they are
characters arranged one after another in
memory. Thus, a character array is called
string.
 Each character within the string is stored
within one element of the array
successively.
 A string is always terminated by a null
character (i.e. slash zero 0).
 A string variable is declared as an
array of characters.
 Syntax:
char string_name[size];
 E.g. char name[20];
 When the compiler assigns a character
string to a character array, it
automatically supplies a null character
(‘0’) at the end of the string
Initializing String
Variables
 Strings are initialized in either of the following two forms:
char name[4]={‘R’,‘A’,‘M’, ‘0’};
char name[]={‘R’,‘A’,‘M’, ‘0’};
OR
char name[4]=“RAM”;
char name[]=“RAM”;
 When we initialize a character array by listing its
elements, the null terminator or the size of the array must
be provided explicitly.
R A M 0
name[0] name[1] name[2] name[3]
Reading and displaying Strings
 It can be done manually.
 Using printf() and scanf().
 Using gets() and puts().
Using printf() and scanf()
SOURCE CODE OUTPUT
Using gets() and puts()
SOURCE CODE OUTPUT
String handling functions
strcpy ( ) Copies str2 into str1
strlen ( ) Gives the length of str1
strcmp ( ) Returns 0 if str1 is same as
str2. Returns <0 if strl <
str2. Returns >0 if str1 > str2
strcmpi ( ) Same as strcmp() function. But,
this function negotiates case. “A”
and “a” are treated as same.
strdup ( ) Duplicates the string
strlwr ( ) Converts string to lowercase
strupr ( ) Converts string to uppercase
strrev ( ) Reverses the given string
Program to find string length using
function
SOURCE CODE OUTPUT
Program to Reverse string using function
SOURCE CODE OUTPUT
DIFFERECE BETWEEN ARRAY AND
STRING
ARRAY STRING
An array can hold any data type. String can hold only char data
An array size can not be A string size can be changed if it
is a char pointer
The last element of an array is an
element of the specific type.
The last character of a string is a
null – ‘0’ character.
The length of an array is to
specified in [] at the time of
declaration (except char[]).
The length of the string is the
number of characters + one (null
character).
Array and string

More Related Content

What's hot

Data types in C language
Data types in C languageData types in C language
Data types in C language
kashyap399
 
Structure in c
Structure in cStructure in c
Structure in c
Prabhu Govind
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
Kamal Acharya
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
String in c programming
String in c programmingString in c programming
String in c programming
Devan Thakur
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and Unions
Dhrumil Patel
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
tanmaymodi4
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Naz Abdalla
 
Strings in c
Strings in cStrings in c
Strings in c
vampugani
 
Array in C
Array in CArray in C
Array in C
Kamal Acharya
 
Structure in C
Structure in CStructure in C
Structure in C
Fazle Rabbi Ador
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Jayanshu Gundaniya
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
madan reddy
 

What's hot (20)

Data types in C language
Data types in C languageData types in C language
Data types in C language
 
Structure in c
Structure in cStructure in c
Structure in c
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
String in c programming
String in c programmingString in c programming
String in c programming
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and Unions
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Strings in c
Strings in cStrings in c
Strings in c
 
Array in C
Array in CArray in C
Array in C
 
Structure in C
Structure in CStructure in C
Structure in C
 
Interface in java
Interface in javaInterface in java
Interface in java
 
String functions in C
String functions in CString functions in C
String functions in C
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
 
Data types
Data typesData types
Data types
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
 

Viewers also liked

Bitwise operators
Bitwise operatorsBitwise operators
Bitwise operators
Puneet Rajput
 
Parm
ParmParm
Parm
parmsidhu
 
principle of oop’s in cpp
principle of oop’s in cppprinciple of oop’s in cpp
principle of oop’s in cpp
gourav kottawar
 
Lecture 11 bitwise_operator
Lecture 11 bitwise_operatorLecture 11 bitwise_operator
Lecture 11 bitwise_operatoreShikshak
 
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programming
Kamal Acharya
 
Inheritance, friend function, virtual function, polymorphism
Inheritance, friend function, virtual function, polymorphismInheritance, friend function, virtual function, polymorphism
Inheritance, friend function, virtual function, polymorphism
Jawad Khan
 
Structures
StructuresStructures
Structures
archikabhatia
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsPrincess Sam
 
C++ Language
C++ LanguageC++ Language
C++ Language
Syed Zaid Irshad
 
Virtual function
Virtual functionVirtual function
Virtual function
harman kaur
 
Embedded c programming22 for fdp
Embedded c programming22 for fdpEmbedded c programming22 for fdp
Embedded c programming22 for fdpPradeep Kumar TS
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
Dr Sukhpal Singh Gill
 
C pointer
C pointerC pointer
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
gourav kottawar
 
Function in C
Function in CFunction in C
Function in C
Dr. Abhineet Anand
 

Viewers also liked (20)

Bitwise operators
Bitwise operatorsBitwise operators
Bitwise operators
 
Parm
ParmParm
Parm
 
principle of oop’s in cpp
principle of oop’s in cppprinciple of oop’s in cpp
principle of oop’s in cpp
 
Lecture 11 bitwise_operator
Lecture 11 bitwise_operatorLecture 11 bitwise_operator
Lecture 11 bitwise_operator
 
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programming
 
Inheritance, friend function, virtual function, polymorphism
Inheritance, friend function, virtual function, polymorphismInheritance, friend function, virtual function, polymorphism
Inheritance, friend function, virtual function, polymorphism
 
Structures
StructuresStructures
Structures
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
 
15 bitwise operators
15 bitwise operators15 bitwise operators
15 bitwise operators
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Embedded c programming22 for fdp
Embedded c programming22 for fdpEmbedded c programming22 for fdp
Embedded c programming22 for fdp
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
C pointer
C pointerC pointer
C pointer
 
Function in c
Function in cFunction in c
Function in c
 
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
 
Function in C
Function in CFunction in C
Function in C
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 

Similar to Array and string

C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
Vikram Nandini
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYRajeshkumar Reddy
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
aroraopticals15
 
Array assignment
Array assignmentArray assignment
Array assignment
Ahmad Kamal
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
Swarup Boro
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
Thesis Scientist Private Limited
 
3.ArraysandPointers.pptx
3.ArraysandPointers.pptx3.ArraysandPointers.pptx
3.ArraysandPointers.pptx
FolkAdonis
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
Shubham Sharma
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
rohinitalekar1
 
Module 4- Arrays and Strings
Module 4- Arrays and StringsModule 4- Arrays and Strings
Module 4- Arrays and Strings
nikshaikh786
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functionsSwarup Kumar Boro
 
C programming session 04
C programming session 04C programming session 04
C programming session 04Dushmanta Nath
 
02 arrays
02 arrays02 arrays
02 arrays
Rajan Gautam
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
Sowri Rajan
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
nmahi96
 
Ocs752 unit 3
Ocs752   unit 3Ocs752   unit 3
Ocs752 unit 3
mgrameshmail
 
Module 3 - Regular Expressions, Dictionaries.pdf
Module 3 - Regular  Expressions,  Dictionaries.pdfModule 3 - Regular  Expressions,  Dictionaries.pdf
Module 3 - Regular Expressions, Dictionaries.pdf
GaneshRaghu4
 

Similar to Array and string (20)

C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
 
Array assignment
Array assignmentArray assignment
Array assignment
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
Arrays
ArraysArrays
Arrays
 
3.ArraysandPointers.pptx
3.ArraysandPointers.pptx3.ArraysandPointers.pptx
3.ArraysandPointers.pptx
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
 
Module 4- Arrays and Strings
Module 4- Arrays and StringsModule 4- Arrays and Strings
Module 4- Arrays and Strings
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
Unit 2
Unit 2Unit 2
Unit 2
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
02 arrays
02 arrays02 arrays
02 arrays
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
 
Ocs752 unit 3
Ocs752   unit 3Ocs752   unit 3
Ocs752 unit 3
 
Module 3 - Regular Expressions, Dictionaries.pdf
Module 3 - Regular  Expressions,  Dictionaries.pdfModule 3 - Regular  Expressions,  Dictionaries.pdf
Module 3 - Regular Expressions, Dictionaries.pdf
 

More from prashant chelani

Traffic engineering topic 19 street lighting
Traffic engineering topic  19 street lightingTraffic engineering topic  19 street lighting
Traffic engineering topic 19 street lighting
prashant chelani
 
Dm = Landslide and Avalanche
Dm = Landslide and AvalancheDm = Landslide and Avalanche
Dm = Landslide and Avalanche
prashant chelani
 
Gate civil engineering
Gate civil engineeringGate civil engineering
Gate civil engineering
prashant chelani
 
Calculus multiple integral
Calculus multiple integralCalculus multiple integral
Calculus multiple integral
prashant chelani
 
TYPES AND INFORMATION STONES
TYPES AND INFORMATION STONESTYPES AND INFORMATION STONES
TYPES AND INFORMATION STONES
prashant chelani
 
Earth magnetic field
Earth magnetic fieldEarth magnetic field
Earth magnetic field
prashant chelani
 
Smartcity
SmartcitySmartcity
Smartcity
prashant chelani
 
Finding value of pie and pythagorus and cryptography
Finding value of pie and pythagorus and cryptographyFinding value of pie and pythagorus and cryptography
Finding value of pie and pythagorus and cryptography
prashant chelani
 

More from prashant chelani (8)

Traffic engineering topic 19 street lighting
Traffic engineering topic  19 street lightingTraffic engineering topic  19 street lighting
Traffic engineering topic 19 street lighting
 
Dm = Landslide and Avalanche
Dm = Landslide and AvalancheDm = Landslide and Avalanche
Dm = Landslide and Avalanche
 
Gate civil engineering
Gate civil engineeringGate civil engineering
Gate civil engineering
 
Calculus multiple integral
Calculus multiple integralCalculus multiple integral
Calculus multiple integral
 
TYPES AND INFORMATION STONES
TYPES AND INFORMATION STONESTYPES AND INFORMATION STONES
TYPES AND INFORMATION STONES
 
Earth magnetic field
Earth magnetic fieldEarth magnetic field
Earth magnetic field
 
Smartcity
SmartcitySmartcity
Smartcity
 
Finding value of pie and pythagorus and cryptography
Finding value of pie and pythagorus and cryptographyFinding value of pie and pythagorus and cryptography
Finding value of pie and pythagorus and cryptography
 

Recently uploaded

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

Array and string

  • 1. Dr. S. & S.S. Gandhy Government College of Engineering and Technology SEM:- 1ST SUBJECT:- COMPUTER PROGRAMMING AND UTILIZATION TOPIC:- ARRAY AND STRING STUDENT’S NAME:- PRATIK B. PATEL PRASHANT A. CHELANI VIJAY D. VADHER NIKHIL R. PATIL
  • 2. ARRAY :-  NEED OF ARRAY  ARRAY CONCEPT  DECLARATION OF ONE- DIMENTIONAL ARRAY  INITIALIZATION OF ONE- DIMENTIONAL ARRAY  MULTYDIMENSIONAL ARRAY
  • 3. NEED OF ARRAY:  It is very difficult to write a program in ‘C’ which consisting large data items like addition of 50 integers, marks of student in University, etc.  ‘C’ program provides a solution called ‘ARRAY’.  By using array, it is easy to include large numbers of data items.
  • 4. ARRAY CONCEPT:-  An array is a group of data items of the same data type that share a common name.  An array should be of same datatype and consists of integers or strings and so on.  An array is linear and homogeneous.  An array stores the data elements in sequential order.  Homogeneous means all data items are of same datatype.
  • 5.  Elements of array are specifying a subscript.  A subscript is also called index.  Subscipt is start from 0 and cannot negative.  There are two types of array.  1). One-dimentional arrays(also called vectors)  2). Multi-dimentional arrays(also called Matrix)
  • 6. DECLARATION OF ONE- DIMENTIONAL ARRAY:-  Syntex: datatype arrayname[size]  Where,  datatype:- The type of the data stored in the array  Arrayname:- Name of the array  Size:- Maximum number of elements an array can hold  Example:- int marks[10] Mark[0] Mark[1] ………….. ………..... Mark[9]
  • 7. INITIALIZATIONOF ONE-DIMENTIONAL ARRAY  Int mark[6]={3,7,8,4,5,6}  Is also equel to  Int mark[]={3,7,8,4,5,6}  It will occupy in memory like,  a[0] a[1] a[2] a[3] a[4] a[5]  Char a[8]={‘L’,’E’,’A’,’R’,’N’,’’,’C’}   a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7]  When compiler sees a character array, it add a null character.So, while declaring a character array, we must allow one extra element space for null character. 3 7 8 4 5 6 ‘L’ ‘E’ ‘A’ ‘R’ ‘N’ ‘’ ‘C’ ‘0’
  • 8. MULTYDIMENSIONAL ARRAY  If an array have more than one dimension, is called multi-dimensional array.  Two dimensional array have two subscript, three dimensional array have three subscript.  Declaration of two dimensional array:-  Int a[2][3]  It consist of two rows and three colomns.  a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2] 1 2 3 4 5 6
  • 10. Program to reverse a array SOURCE CODE OUTPUT
  • 11. Strings  INTRODUCTION  INITIALIZING STRING VARIABLES  READING AND DISPLAYING STRINGS  STRING HANDLING FUNCTIONS  PROGRAMS OF STRING
  • 12. INTRODUCTION :-  Strings are array of characters i.e. they are characters arranged one after another in memory. Thus, a character array is called string.  Each character within the string is stored within one element of the array successively.  A string is always terminated by a null character (i.e. slash zero 0).
  • 13.  A string variable is declared as an array of characters.  Syntax: char string_name[size];  E.g. char name[20];  When the compiler assigns a character string to a character array, it automatically supplies a null character (‘0’) at the end of the string
  • 14. Initializing String Variables  Strings are initialized in either of the following two forms: char name[4]={‘R’,‘A’,‘M’, ‘0’}; char name[]={‘R’,‘A’,‘M’, ‘0’}; OR char name[4]=“RAM”; char name[]=“RAM”;  When we initialize a character array by listing its elements, the null terminator or the size of the array must be provided explicitly. R A M 0 name[0] name[1] name[2] name[3]
  • 15. Reading and displaying Strings  It can be done manually.  Using printf() and scanf().  Using gets() and puts().
  • 16. Using printf() and scanf() SOURCE CODE OUTPUT
  • 17. Using gets() and puts() SOURCE CODE OUTPUT
  • 18. String handling functions strcpy ( ) Copies str2 into str1 strlen ( ) Gives the length of str1 strcmp ( ) Returns 0 if str1 is same as str2. Returns <0 if strl < str2. Returns >0 if str1 > str2 strcmpi ( ) Same as strcmp() function. But, this function negotiates case. “A” and “a” are treated as same. strdup ( ) Duplicates the string strlwr ( ) Converts string to lowercase strupr ( ) Converts string to uppercase strrev ( ) Reverses the given string
  • 19. Program to find string length using function SOURCE CODE OUTPUT
  • 20. Program to Reverse string using function SOURCE CODE OUTPUT
  • 21. DIFFERECE BETWEEN ARRAY AND STRING ARRAY STRING An array can hold any data type. String can hold only char data An array size can not be A string size can be changed if it is a char pointer The last element of an array is an element of the specific type. The last character of a string is a null – ‘0’ character. The length of an array is to specified in [] at the time of declaration (except char[]). The length of the string is the number of characters + one (null character).