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
Ad

More Related Content

What's hot (20)

Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Rokonuzzaman Rony
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
Ritika Sharma
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
Arrays In C
Arrays In CArrays In C
Arrays In C
yndaravind
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
Rajendran
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Strings
StringsStrings
Strings
Nilesh Dalvi
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
Dr.Subha Krishna
 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++
Sachin Yadav
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
C programming - String
C programming - StringC programming - String
C programming - String
Achyut Devkota
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
structure and union
structure and unionstructure and union
structure and union
student
 
Call by value
Call by valueCall by value
Call by value
Dharani G
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
Megha V
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
Awais Alam
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
tanmaymodi4
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
Kamal Acharya
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
Ritika Sharma
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
Rajendran
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++
Sachin Yadav
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
C programming - String
C programming - StringC programming - String
C programming - String
Achyut Devkota
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
structure and union
structure and unionstructure and union
structure and union
student
 
Call by value
Call by valueCall by value
Call by value
Dharani G
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
Megha V
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
tanmaymodi4
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
Kamal Acharya
 

Viewers also liked (20)

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_operator
eShikshak
 
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.functions
Princess Sam
 
15 bitwise operators
15 bitwise operators15 bitwise operators
15 bitwise operators
Ravindra Rathore
 
C++ Language
C++ LanguageC++ Language
C++ Language
Syed Zaid Irshad
 
Virtual function
Virtual functionVirtual function
Virtual function
harman kaur
 
Functions in C
Functions in CFunctions in C
Functions in C
Shobhit Upadhyay
 
Embedded c programming22 for fdp
Embedded c programming22 for fdpEmbedded c programming22 for fdp
Embedded c programming22 for fdp
Pradeep Kumar TS
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
Dr Sukhpal Singh Gill
 
C pointer
C pointerC pointer
C pointer
University of Potsdam
 
Function in c
Function in cFunction in c
Function in c
Raj Tandukar
 
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
 
C Pointers
C PointersC Pointers
C Pointers
omukhtar
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
Kulachi Hansraj Model School Ashok Vihar
 
Ad

Similar to Array and string (20)

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 REDDY
Rajeshkumar Reddy
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
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
 
Arrays
ArraysArrays
Arrays
Chukka Nikhil Chakravarthy
 
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 vectors in Data Structure.ppt
Arrays and vectors in Data Structure.pptArrays and vectors in Data Structure.ppt
Arrays and vectors in Data Structure.ppt
mazanali7145
 
ARRAY's in C Programming Language PPTX.
ARRAY's in C  Programming Language PPTX.ARRAY's in C  Programming Language PPTX.
ARRAY's in C Programming Language PPTX.
MSridhar18
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
Swarup Kumar Boro
 
Unit 2
Unit 2Unit 2
Unit 2
Sowri Rajan
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
Dushmanta Nath
 
Array and its operation in C programming
Array and its operation in C programmingArray and its operation in C programming
Array and its operation in C programming
Rhishav Poudyal
 
02 arrays
02 arrays02 arrays
02 arrays
Rajan Gautam
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
Sowri Rajan
 
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
Rajeshkumar 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
 
3.ArraysandPointers.pptx
3.ArraysandPointers.pptx3.ArraysandPointers.pptx
3.ArraysandPointers.pptx
FolkAdonis
 
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 vectors in Data Structure.ppt
Arrays and vectors in Data Structure.pptArrays and vectors in Data Structure.ppt
Arrays and vectors in Data Structure.ppt
mazanali7145
 
ARRAY's in C Programming Language PPTX.
ARRAY's in C  Programming Language PPTX.ARRAY's in C  Programming Language PPTX.
ARRAY's in C Programming Language PPTX.
MSridhar18
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
Swarup Kumar Boro
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
Dushmanta Nath
 
Array and its operation in C programming
Array and its operation in C programmingArray and its operation in C programming
Array and its operation in C programming
Rhishav Poudyal
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
Sowri Rajan
 
Ad

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

Recently uploaded (20)

How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Phoenix – A Collaborative Renewal of Children’s and Young People’s Services C...
Library Association of Ireland
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 

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