SlideShare a Scribd company logo
1 of 30
INTRODUCTION TO ARRAY AND STRING
Team Members:
Sajid Anowar
ID: 191-35-390
Muntasir Muhit
ID: 191-35-399
Array
CONTENT:
• Array
• Types of Array
Array
An array is a collection of one or more values of the
same type. Each value is called an element of
the array. The elements of the array share the same
variable name but each element has its own unique
index number (also known as a subscript). An
array can be of any type:
For example: int , float , char etc.
Syntax
data-type name[size1][size2]………[sizen];
Example: int a[6];
Array
Advantage of Array
• Huge amount of data can be stored under single variable name.
• Searching of data item is faster.
• 2 dimension arrays are used to represent the matrices.
• It is helpful in implementing other data structure like linked list,
queue, stack.
Types of Array
One Dimensional Array
A one-dimensional
array (or single dimension
array) is a type of
linear array. Accessing its
elements involves
a single subscript which can
either represent a row or
column index.
SYNTAX: data-type name[index];
EXAMPLE: int num[10];
Initialization
• int num[6]={2,4,6,7,8,12};
• Individual elements can also be initialize as:
num[0]=2;
num[1]=4;
num[2]=6;
num[3]=7;
num[4]=8;
num[5]=12;
Reading Data from User
• for loop is used to read data from the user.
for(i=0;i<10;i++)
{
scanf(“%d”,&num[i]);
}
MULTI DIMENTIONAL ARRAY
The two dimensional (2D) array
in C programming is also
known as matrix. A matrix
can be represented as a
table of rows and columns
SYNTAX: data-type name[row-size][column-size];
EXAMPLE: int a[3][4];
Initialization
• int odd[3][2]={1,3,5,7,9,11};
Individual element can also be assigned as:
Odd[0][0]=1;
Odd[0][1]=3;
Odd[1][0]=5;
Odd[1][1]=7;
Odd[2][0]=9;
Odd[2][1]=11;
Reading Data from User
• Nested for Loop is used.
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf(“%d”,&odd[i] [j]);
}
STRING
WHAT IS STRING ?
A group of characters A string constant is a one-
dimensional array
of characters terminated by a null ( ‘0’ ).
declaration of Character:
• char mychar;
declaration of String:
• char myString[10];
The characters after the null character are ignored.
WHAT IS NULL char ?
• Null ‘0’ is a terminator which terminates the string in an array
WHY NULL char ?
When declaring a string don’t forget to leave a space for the null
character which is also known as the string terminator character
only way the functions that work with a string can know where the
string ends.
INPUT FUNCTION
• Input Function :
The scanf() Function
• header file stdio.h
• Syntax:
• char mystring[100];
• scanf(“%s”, mystring);
The name of a string is a pointer constant to the first character in the character
array.
Problem:
terminates its input on the first white space it finds.
white space includes blanks, tabs, carriage returns(CR), form feeds & new line.
EXAMPLE
PROGRAM OUTPUT
INPUT FUNCTION
The gets() Function:
Header file stdio.h
takes a string from standard input and assigns it to a character array.
It replaces the n with 0.
Syntax:
• char mystring[100];
• gets(myString);
• fgets() it keeps the n and includes it as part of the string.
EXAMPLE
PROGRAM OUTPUT
OUTPUT FUNCTION
The printf () function
header file: stdio.h
The puts() function
header file: stdio.h
PROGRAM
OUTPUT
STRING OPERATION(string.h)
Four main library function which is define in
• string.h header file
• strcpy() - copy one string into another
• strcat() - append one string onto the right side of
• the other
• strcmp() – compare alphabetic order of two
• strings
• strlen() – return the length of a string
Strcpy()
PROGRAM OUTPUT
strcat()
PROGRAM OUTPUT
Strcmp()
PROGRAM OUTPUT
Strlen()
PROGRAM OUTPUT
MORE FUNCTIONS
• strlwr() : converts a string to lowercase
• Strupr() : converts a string to uppercase
• Strncat() : Appends first n characters of a string at the end of
another
• Strncmp() :Compares first n characters of two strings
• Strcmpi():Compares two strings without regard to case ("i" denotes
that this function ignores Case)
• [Note: There are more library functions…..]
EXAMPLE
PROGRAM OUTPUT
Introduction to array and string

More Related Content

What's hot (20)

Arrays
ArraysArrays
Arrays
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Python tuple
Python   tuplePython   tuple
Python tuple
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and Unions
 
Linked List
Linked ListLinked List
Linked List
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
 
structure and union
structure and unionstructure and union
structure and union
 
String in c programming
String in c programmingString in c programming
String in c programming
 
Lists
ListsLists
Lists
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
C++ string
C++ stringC++ string
C++ string
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Array and string
Array and stringArray and string
Array and string
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
Arrays
ArraysArrays
Arrays
 
Chapter 17 Tuples
Chapter 17 TuplesChapter 17 Tuples
Chapter 17 Tuples
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Strings in C
Strings in CStrings in C
Strings in C
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Pointers in c v5 12102017 1
Pointers in c v5 12102017 1Pointers in c v5 12102017 1
Pointers in c v5 12102017 1
 

Similar to Introduction to array and string

Similar to Introduction to array and string (20)

Array , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptxArray , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptx
 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Module 4- Arrays and Strings
Module 4- Arrays and StringsModule 4- Arrays and Strings
Module 4- Arrays and Strings
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
 
Chapter 13.1.7
Chapter 13.1.7Chapter 13.1.7
Chapter 13.1.7
 
C-Programming Arrays.pptx
C-Programming  Arrays.pptxC-Programming  Arrays.pptx
C-Programming Arrays.pptx
 
C-Programming Arrays.pptx
C-Programming  Arrays.pptxC-Programming  Arrays.pptx
C-Programming Arrays.pptx
 
Unit 2
Unit 2Unit 2
Unit 2
 
Numpy.pdf
Numpy.pdfNumpy.pdf
Numpy.pdf
 
Session 4
Session 4Session 4
Session 4
 
Language R
Language RLanguage R
Language R
 
ACP-arrays.pptx
ACP-arrays.pptxACP-arrays.pptx
ACP-arrays.pptx
 
DataStructures.pptx
DataStructures.pptxDataStructures.pptx
DataStructures.pptx
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Strings in programming tutorial.
Strings  in programming tutorial.Strings  in programming tutorial.
Strings in programming tutorial.
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
Arrays
ArraysArrays
Arrays
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
 

More from MuntasirMuhit

Presentation on Airpollution Modeling
Presentation on Airpollution ModelingPresentation on Airpollution Modeling
Presentation on Airpollution ModelingMuntasirMuhit
 
Presentation on graphics processing unit (GPU)
Presentation on graphics processing unit (GPU)Presentation on graphics processing unit (GPU)
Presentation on graphics processing unit (GPU)MuntasirMuhit
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data StructureMuntasirMuhit
 
Statistics in real life
Statistics in real lifeStatistics in real life
Statistics in real lifeMuntasirMuhit
 
Discrete mathematics for real world applications
Discrete mathematics for real world applicationsDiscrete mathematics for real world applications
Discrete mathematics for real world applicationsMuntasirMuhit
 
Programming languages
Programming languagesProgramming languages
Programming languagesMuntasirMuhit
 

More from MuntasirMuhit (6)

Presentation on Airpollution Modeling
Presentation on Airpollution ModelingPresentation on Airpollution Modeling
Presentation on Airpollution Modeling
 
Presentation on graphics processing unit (GPU)
Presentation on graphics processing unit (GPU)Presentation on graphics processing unit (GPU)
Presentation on graphics processing unit (GPU)
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
Statistics in real life
Statistics in real lifeStatistics in real life
Statistics in real life
 
Discrete mathematics for real world applications
Discrete mathematics for real world applicationsDiscrete mathematics for real world applications
Discrete mathematics for real world applications
 
Programming languages
Programming languagesProgramming languages
Programming languages
 

Recently uploaded

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Recently uploaded (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

Introduction to array and string

  • 1. INTRODUCTION TO ARRAY AND STRING Team Members: Sajid Anowar ID: 191-35-390 Muntasir Muhit ID: 191-35-399
  • 3. Array An array is a collection of one or more values of the same type. Each value is called an element of the array. The elements of the array share the same variable name but each element has its own unique index number (also known as a subscript). An array can be of any type: For example: int , float , char etc.
  • 6. Advantage of Array • Huge amount of data can be stored under single variable name. • Searching of data item is faster. • 2 dimension arrays are used to represent the matrices. • It is helpful in implementing other data structure like linked list, queue, stack.
  • 8. One Dimensional Array A one-dimensional array (or single dimension array) is a type of linear array. Accessing its elements involves a single subscript which can either represent a row or column index. SYNTAX: data-type name[index]; EXAMPLE: int num[10];
  • 9. Initialization • int num[6]={2,4,6,7,8,12}; • Individual elements can also be initialize as: num[0]=2; num[1]=4; num[2]=6; num[3]=7; num[4]=8; num[5]=12;
  • 10. Reading Data from User • for loop is used to read data from the user. for(i=0;i<10;i++) { scanf(“%d”,&num[i]); }
  • 11. MULTI DIMENTIONAL ARRAY The two dimensional (2D) array in C programming is also known as matrix. A matrix can be represented as a table of rows and columns SYNTAX: data-type name[row-size][column-size]; EXAMPLE: int a[3][4];
  • 12. Initialization • int odd[3][2]={1,3,5,7,9,11}; Individual element can also be assigned as: Odd[0][0]=1; Odd[0][1]=3; Odd[1][0]=5; Odd[1][1]=7; Odd[2][0]=9; Odd[2][1]=11;
  • 13. Reading Data from User • Nested for Loop is used. for(i=0;i<3;i++) { for(j=0;j<2;j++) scanf(“%d”,&odd[i] [j]); }
  • 15. WHAT IS STRING ? A group of characters A string constant is a one- dimensional array of characters terminated by a null ( ‘0’ ). declaration of Character: • char mychar; declaration of String: • char myString[10]; The characters after the null character are ignored.
  • 16. WHAT IS NULL char ? • Null ‘0’ is a terminator which terminates the string in an array
  • 17. WHY NULL char ? When declaring a string don’t forget to leave a space for the null character which is also known as the string terminator character only way the functions that work with a string can know where the string ends.
  • 18. INPUT FUNCTION • Input Function : The scanf() Function • header file stdio.h • Syntax: • char mystring[100]; • scanf(“%s”, mystring); The name of a string is a pointer constant to the first character in the character array. Problem: terminates its input on the first white space it finds. white space includes blanks, tabs, carriage returns(CR), form feeds & new line.
  • 20. INPUT FUNCTION The gets() Function: Header file stdio.h takes a string from standard input and assigns it to a character array. It replaces the n with 0. Syntax: • char mystring[100]; • gets(myString); • fgets() it keeps the n and includes it as part of the string.
  • 22. OUTPUT FUNCTION The printf () function header file: stdio.h The puts() function header file: stdio.h PROGRAM OUTPUT
  • 23. STRING OPERATION(string.h) Four main library function which is define in • string.h header file • strcpy() - copy one string into another • strcat() - append one string onto the right side of • the other • strcmp() – compare alphabetic order of two • strings • strlen() – return the length of a string
  • 28. MORE FUNCTIONS • strlwr() : converts a string to lowercase • Strupr() : converts a string to uppercase • Strncat() : Appends first n characters of a string at the end of another • Strncmp() :Compares first n characters of two strings • Strcmpi():Compares two strings without regard to case ("i" denotes that this function ignores Case) • [Note: There are more library functions…..]