SlideShare a Scribd company logo
An Introduction to Pointers
• A pointer(address variable) is a variable whose value is used to point to
another variable.
Ex:
long int x, y;
y = &x;
(assigns address of the long integer variable x to another variable, y.)
Ex:
#include <stdio.h>
main()
{
char c;
int x;
float y;
printf("c: address=0x%p, content=%cn", &c, c);
printf("x: address=0x%p, content=%dn", &x, x);
printf("y: address=0x%p, content=%5.2fn", &y, y);
c = `A';
x = 7;
y = 123.45;
printf("c: address=0x%p, content=%cn", &c, c);
printf("x: address=0x%p, content=%dn", &x, x);
printf("y: address=0x%p, content=%5.2fn", &y, y);
return 0;
}
NOTE: %p, %u, %lu
• Pointer has Left value and Right value.
– Left value: address its self
– Right value: which is the content of the pointer, is the address of another variable.
– data-type *pointer-name;
• Ex:
#include <stdio.h>
main()
{
char c, *ptr_c;
int x, *ptr_x;
float y, *ptr_y;
c = `A';
x = 7;
y = 123.45;
printf("c: address=0x%p, content=%cn", &c, c);
printf("x: address=0x%p, content=%dn", &x, x);
printf("y: address=0x%p, content=%5.2fn", &y, y);
ptr_c = &c;
printf("ptr_c: address=0x%p, content=0x%pn", &ptr_c, ptr_c);
printf("*ptr_c => %cn", *ptr_c);
ptr_x = &x;
printf("ptr_x: address=0x%p, content=0x%pn", &ptr_x, ptr_x);
printf("*ptr_x => %dn", *ptr_x);
ptr_y = &y;
printf("ptr_y: address=0x%p, content=0x%pn", &ptr_y, ptr_y);
printf("*ptr_y => %5.2fn", *ptr_y);
return 0;
}
Storing Similar Data Items
• array is a collection of variables that are of the same data type.
– data-type Array-Name[Array-Size];
EX:
#include <stdio.h>
main()
{
int i;
int list_int[10];
for (i=0; i<10; i++){
list_int[i] = i + 1;
printf( "list_int[%d] is initialized with %d.n", i, list_int[i]);
}
return 0;
}
One dimensionl Array
• One dimensional array
– Int a[10], float x[50], char str[30];
– Int a[10]={12,3,4,65,6,2,3}; int
a[]={1,2,3,4,5,6,7,8};
– Char str[30]=“Hello how well?”;
– ‘0’=null remain
Ex:
#include <stdio.h>
main()
{
char array_ch[7] = {`H', `e', `l', `l', `o', `!’};
int i;
for (i=0; i<7; i++)
printf("array_ch[%d] contains: %cn", i, array_ch[i]);
/*--- method I ---*/
printf( "Put all elements together(Method I):n");
for (i=0; i<7; i++)
printf("%c", array_ch[i]);
/*--- method II ---*/
printf( "nPut all elements together(Method II):n");
printf( "%sn", array_ch);
return 0;
}
Ex:
#include <stdio.h>
main()
{
char array_ch[15] = {`C', ` `,
`i', `s', ` `,
`p', `o', `w', `e', `r',
`f', `u', `l', `!', `0'};
int i;
/* array_ch[i] in logical test */
for (i=0; array_ch[i] != `0'; i++)
printf("%c", array_ch[i]);
return 0;
}
INSERT, SEARCH, SORT, DELETE in one
demensional Array
Multidimensional Arrays
• data-type Array-Name[Array-Size1][Array-
Size2]. . .[Array-SizeN];
– int array_int[2][3];
– int array_int[2][3] = {{1, 2, 3}, {4, 5, 6}};
Unsized Arrays
• int list_int[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90};
• char list_ch[][2] = { `7', `A', `b', `B',`c', `C',`d',
`D',`e', `E', `f', `F',`g', `G'};
Manipulating Strings
• a string is a character array terminated by a
null character (0).
• char array_ch[7] = {`H', `e', `l', `l', `o', `!', `0'};
• char str[7] = "Hello!";
• char str[] = "I like C.";
• char *ptr_str = "I teach myself C.";
• char ch = `x';
• char str[] = "x";
• char *ptr_str;
ptr_str = "A character string.";
#include <stdio.h>
main()
{
char str1[] = {`A', ` `,
`s', `t', `r', `i', `n', `g', ` `,
`c', `o', `n', `s', `t', `a', `n', `t', `0'};
char str2[] = "Another string constant";
char *ptr_str;
int i;
/* print out str2 */
for (i=0; str1[i]; i++)
printf("%c", str1[i]);
printf("n");
/* print out str2 */
for (i=0; str2[i]; i++)
printf("%c", str2[i]);
printf("n");
/* assign a string to a pointer */
ptr_str = "Assign a string to a pointer.";
for (i=0; *ptr_str; i++)
printf("%c", *ptr_str++);
return 0;
}
#include <stdio.h>
main()
{
char str[80];
int i, delt = `a' - `A';
printf("Enter a string less than 80 characters:n");
gets( str );
i = 0;
while (str[i]){
if ((str[i] >= `a') && (str[i] <= `z'))
str[i] -= delt; /* convert to upper case */
++i;
}
printf("The entered string is (in uppercase):n");
puts( str );
return 0;
}
char *str = "Hello World!";
• Alternatively one might think that a pointer to string in C is a pointer to a char array
/ a pointer to a pointer to a char.
• char *str = "Hello World!";
– str is a pointer to a string.
– str is a pointer to a char array.
– But str is a pointer to a char (not a pointer to a pointer to a
char). str is of type char * .(and here str points to H).
– Ended by 0 null
– char *v1=“A”; 2 bytes
– char v1=‘A’; 1 byte
– ‘A’ + 20 + ‘C’ but not “A” + 20 + “C”
H e l l o W o r l ! 0
A 0
A
Arr[6]=“12345”;
• char arr[6]=“gfhgf”;
• char arr[6]={‘1’,’2’,’3’,’4’,’5’};
• char arr[]=“3212432432”;
1 2 3 4 5 0

More Related Content

What's hot

C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
vinay arora
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
vinay arora
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structures
vinay arora
 
Implementing string
Implementing stringImplementing string
Implementing string
mohamed sikander
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C lab manaual
C lab manaualC lab manaual
C lab manaual
manoj11manu
 
Double linked list
Double linked listDouble linked list
Double linked list
Sayantan Sur
 
C questions
C questionsC questions
C questions
mohamed sikander
 
C Prog - Strings
C Prog - StringsC Prog - Strings
C Prog - Strings
vinay arora
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
C programms
C programmsC programms
C programms
Mukund Gandrakota
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
ADA FILE
ADA FILEADA FILE
ADA FILE
Gaurav Singh
 
C Programming Language Part 11
C Programming Language Part 11C Programming Language Part 11
C Programming Language Part 11
Rumman Ansari
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
Array
ArrayArray
C programming
C programmingC programming
C programming
Samsil Arefin
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
mohamed sikander
 
Double linked list
Double linked listDouble linked list
Double linked list
raviahuja11
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
Rumman Ansari
 

What's hot (20)

C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structures
 
Implementing string
Implementing stringImplementing string
Implementing string
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Double linked list
Double linked listDouble linked list
Double linked list
 
C questions
C questionsC questions
C questions
 
C Prog - Strings
C Prog - StringsC Prog - Strings
C Prog - Strings
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
C programms
C programmsC programms
C programms
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
C Programming Language Part 11
C Programming Language Part 11C Programming Language Part 11
C Programming Language Part 11
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Array
ArrayArray
Array
 
C programming
C programmingC programming
C programming
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Double linked list
Double linked listDouble linked list
Double linked list
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
 

Similar to 4. chapter iii

C basics
C basicsC basics
C basics
MSc CST
 
12 1 문자열
12 1 문자열12 1 문자열
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
Syed Tanveer
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
vinay arora
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
Er Ritu Aggarwal
 
Cpds lab
Cpds labCpds lab
Array Programs.pdf
Array Programs.pdfArray Programs.pdf
Array Programs.pdf
RajKamal557276
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
Arkadeep Dey
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
Sazzad Hossain, ITP, MBA, CSCA™
 
Unit 3 Input Output.pptx
Unit 3 Input Output.pptxUnit 3 Input Output.pptx
Unit 3 Input Output.pptx
Precise Mya
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++
Eli Diaz
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++
Eli Diaz
 
Ds
DsDs
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
Strings in C
Strings in CStrings in C
String
StringString
String
SANTOSH RATH
 
Examples sandhiya class'
Examples sandhiya class'Examples sandhiya class'
Examples sandhiya class'
Dr.Sandhiya Ravi
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
Prof. Dr. K. Adisesha
 

Similar to 4. chapter iii (20)

C basics
C basicsC basics
C basics
 
12 1 문자열
12 1 문자열12 1 문자열
12 1 문자열
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Array Programs.pdf
Array Programs.pdfArray Programs.pdf
Array Programs.pdf
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
Unit 3 Input Output.pptx
Unit 3 Input Output.pptxUnit 3 Input Output.pptx
Unit 3 Input Output.pptx
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
 
(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++
 
Ds
DsDs
Ds
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Strings in C
Strings in CStrings in C
Strings in C
 
String
StringString
String
 
Examples sandhiya class'
Examples sandhiya class'Examples sandhiya class'
Examples sandhiya class'
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 

More from Chhom Karath

set1.pdf
set1.pdfset1.pdf
set1.pdf
Chhom Karath
 
Set1.pptx
Set1.pptxSet1.pptx
Set1.pptx
Chhom Karath
 
orthodontic patient education.pdf
orthodontic patient education.pdforthodontic patient education.pdf
orthodontic patient education.pdf
Chhom Karath
 
New ton 3.pdf
New ton 3.pdfNew ton 3.pdf
New ton 3.pdf
Chhom Karath
 
ច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptxច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptx
Chhom Karath
 
Control tipping.pptx
Control tipping.pptxControl tipping.pptx
Control tipping.pptx
Chhom Karath
 
Bulbous loop.pptx
Bulbous loop.pptxBulbous loop.pptx
Bulbous loop.pptx
Chhom Karath
 
brush teeth.pptx
brush teeth.pptxbrush teeth.pptx
brush teeth.pptx
Chhom Karath
 
bracket size.pptx
bracket size.pptxbracket size.pptx
bracket size.pptx
Chhom Karath
 
arch form KORI copy.pptx
arch form KORI copy.pptxarch form KORI copy.pptx
arch form KORI copy.pptx
Chhom Karath
 
Bracket size
Bracket sizeBracket size
Bracket size
Chhom Karath
 
Couple
CoupleCouple
Couple
Chhom Karath
 
ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣
Chhom Karath
 
Game1
Game1Game1
Shoe horn loop
Shoe horn loopShoe horn loop
Shoe horn loop
Chhom Karath
 
Opus loop
Opus loopOpus loop
Opus loop
Chhom Karath
 
V bend
V bendV bend
V bend
Chhom Karath
 
Closing loop
Closing loopClosing loop
Closing loop
Chhom Karath
 
Maxillary arch form
Maxillary arch formMaxillary arch form
Maxillary arch form
Chhom Karath
 
Front face analysis
Front face analysisFront face analysis
Front face analysis
Chhom Karath
 

More from Chhom Karath (20)

set1.pdf
set1.pdfset1.pdf
set1.pdf
 
Set1.pptx
Set1.pptxSet1.pptx
Set1.pptx
 
orthodontic patient education.pdf
orthodontic patient education.pdforthodontic patient education.pdf
orthodontic patient education.pdf
 
New ton 3.pdf
New ton 3.pdfNew ton 3.pdf
New ton 3.pdf
 
ច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptxច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptx
 
Control tipping.pptx
Control tipping.pptxControl tipping.pptx
Control tipping.pptx
 
Bulbous loop.pptx
Bulbous loop.pptxBulbous loop.pptx
Bulbous loop.pptx
 
brush teeth.pptx
brush teeth.pptxbrush teeth.pptx
brush teeth.pptx
 
bracket size.pptx
bracket size.pptxbracket size.pptx
bracket size.pptx
 
arch form KORI copy.pptx
arch form KORI copy.pptxarch form KORI copy.pptx
arch form KORI copy.pptx
 
Bracket size
Bracket sizeBracket size
Bracket size
 
Couple
CoupleCouple
Couple
 
ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣
 
Game1
Game1Game1
Game1
 
Shoe horn loop
Shoe horn loopShoe horn loop
Shoe horn loop
 
Opus loop
Opus loopOpus loop
Opus loop
 
V bend
V bendV bend
V bend
 
Closing loop
Closing loopClosing loop
Closing loop
 
Maxillary arch form
Maxillary arch formMaxillary arch form
Maxillary arch form
 
Front face analysis
Front face analysisFront face analysis
Front face analysis
 

Recently uploaded

Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 

Recently uploaded (20)

Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 

4. chapter iii

  • 2.
  • 3. • A pointer(address variable) is a variable whose value is used to point to another variable. Ex: long int x, y; y = &x; (assigns address of the long integer variable x to another variable, y.) Ex: #include <stdio.h> main() { char c; int x; float y; printf("c: address=0x%p, content=%cn", &c, c); printf("x: address=0x%p, content=%dn", &x, x); printf("y: address=0x%p, content=%5.2fn", &y, y); c = `A'; x = 7; y = 123.45; printf("c: address=0x%p, content=%cn", &c, c); printf("x: address=0x%p, content=%dn", &x, x); printf("y: address=0x%p, content=%5.2fn", &y, y); return 0; } NOTE: %p, %u, %lu
  • 4. • Pointer has Left value and Right value. – Left value: address its self – Right value: which is the content of the pointer, is the address of another variable. – data-type *pointer-name; • Ex: #include <stdio.h> main() { char c, *ptr_c; int x, *ptr_x; float y, *ptr_y; c = `A'; x = 7; y = 123.45; printf("c: address=0x%p, content=%cn", &c, c); printf("x: address=0x%p, content=%dn", &x, x); printf("y: address=0x%p, content=%5.2fn", &y, y); ptr_c = &c; printf("ptr_c: address=0x%p, content=0x%pn", &ptr_c, ptr_c); printf("*ptr_c => %cn", *ptr_c); ptr_x = &x; printf("ptr_x: address=0x%p, content=0x%pn", &ptr_x, ptr_x); printf("*ptr_x => %dn", *ptr_x); ptr_y = &y; printf("ptr_y: address=0x%p, content=0x%pn", &ptr_y, ptr_y); printf("*ptr_y => %5.2fn", *ptr_y); return 0; }
  • 5. Storing Similar Data Items • array is a collection of variables that are of the same data type. – data-type Array-Name[Array-Size]; EX: #include <stdio.h> main() { int i; int list_int[10]; for (i=0; i<10; i++){ list_int[i] = i + 1; printf( "list_int[%d] is initialized with %d.n", i, list_int[i]); } return 0; }
  • 6. One dimensionl Array • One dimensional array – Int a[10], float x[50], char str[30]; – Int a[10]={12,3,4,65,6,2,3}; int a[]={1,2,3,4,5,6,7,8}; – Char str[30]=“Hello how well?”; – ‘0’=null remain
  • 7. Ex: #include <stdio.h> main() { char array_ch[7] = {`H', `e', `l', `l', `o', `!’}; int i; for (i=0; i<7; i++) printf("array_ch[%d] contains: %cn", i, array_ch[i]); /*--- method I ---*/ printf( "Put all elements together(Method I):n"); for (i=0; i<7; i++) printf("%c", array_ch[i]); /*--- method II ---*/ printf( "nPut all elements together(Method II):n"); printf( "%sn", array_ch); return 0; } Ex: #include <stdio.h> main() { char array_ch[15] = {`C', ` `, `i', `s', ` `, `p', `o', `w', `e', `r', `f', `u', `l', `!', `0'}; int i; /* array_ch[i] in logical test */ for (i=0; array_ch[i] != `0'; i++) printf("%c", array_ch[i]); return 0; }
  • 8. INSERT, SEARCH, SORT, DELETE in one demensional Array
  • 9. Multidimensional Arrays • data-type Array-Name[Array-Size1][Array- Size2]. . .[Array-SizeN]; – int array_int[2][3]; – int array_int[2][3] = {{1, 2, 3}, {4, 5, 6}};
  • 10. Unsized Arrays • int list_int[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90}; • char list_ch[][2] = { `7', `A', `b', `B',`c', `C',`d', `D',`e', `E', `f', `F',`g', `G'};
  • 11. Manipulating Strings • a string is a character array terminated by a null character (0). • char array_ch[7] = {`H', `e', `l', `l', `o', `!', `0'}; • char str[7] = "Hello!"; • char str[] = "I like C."; • char *ptr_str = "I teach myself C.";
  • 12. • char ch = `x'; • char str[] = "x"; • char *ptr_str; ptr_str = "A character string.";
  • 13. #include <stdio.h> main() { char str1[] = {`A', ` `, `s', `t', `r', `i', `n', `g', ` `, `c', `o', `n', `s', `t', `a', `n', `t', `0'}; char str2[] = "Another string constant"; char *ptr_str; int i; /* print out str2 */ for (i=0; str1[i]; i++) printf("%c", str1[i]); printf("n"); /* print out str2 */ for (i=0; str2[i]; i++) printf("%c", str2[i]); printf("n"); /* assign a string to a pointer */ ptr_str = "Assign a string to a pointer."; for (i=0; *ptr_str; i++) printf("%c", *ptr_str++); return 0; }
  • 14. #include <stdio.h> main() { char str[80]; int i, delt = `a' - `A'; printf("Enter a string less than 80 characters:n"); gets( str ); i = 0; while (str[i]){ if ((str[i] >= `a') && (str[i] <= `z')) str[i] -= delt; /* convert to upper case */ ++i; } printf("The entered string is (in uppercase):n"); puts( str ); return 0; }
  • 15. char *str = "Hello World!"; • Alternatively one might think that a pointer to string in C is a pointer to a char array / a pointer to a pointer to a char. • char *str = "Hello World!"; – str is a pointer to a string. – str is a pointer to a char array. – But str is a pointer to a char (not a pointer to a pointer to a char). str is of type char * .(and here str points to H). – Ended by 0 null – char *v1=“A”; 2 bytes – char v1=‘A’; 1 byte – ‘A’ + 20 + ‘C’ but not “A” + 20 + “C” H e l l o W o r l ! 0 A 0 A
  • 16. Arr[6]=“12345”; • char arr[6]=“gfhgf”; • char arr[6]={‘1’,’2’,’3’,’4’,’5’}; • char arr[]=“3212432432”; 1 2 3 4 5 0

Editor's Notes

  1. #include<stdio.h> #include<conio.h> void main() { clrscr(); int k,n; int d[60]; printf("Enter n:"); scanf("%d",&n); //insert for(int i=0;i<n;i++) { printf("Enter d[%d]=",i); scanf("%d",&d[i]); } //duplicate for( i=0;i<n-1;i++) for(int j=i+1;j<n;j++) { if(d[i]==d[j]) { n=n-1; for(k=j;k<n;k++) { d[k]=d[k+1]; } j--; } } //sort DESC int t; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(d[i]<d[j]) { t=d[i]; d[i]=d[j]; d[j]=t; } //Delete int dn; printf("Enter number to delete:");scanf("%d",&dn); for(i=0;i<n;i++) { if(dn==d[i]) { n=n-1; for(j=i;j<n;j++) d[j]=d[j+1]; i--; } } //search int b=1; int sn; printf("Enter number to search:");scanf("%d",&sn); for(i=0;i<n;i++) { if(sn==d[i]) b=0; } if(b==1) { printf("Not Found"); } else { printf("I Found"); } //output for(i=0;i<n;i++) { printf("d[%d]=%d\n",i,d[i]); } getch(); }