SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Arrays Session 7
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Array Elements & Indices ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Defining an Array-1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],.
Defining an Array-2 ,[object Object],[object Object],[object Object]
Norms with Arrays ,[object Object],[object Object],[object Object],[object Object]
Array Handling in C-1 ,[object Object],[object Object],[object Object],[object Object]
Array Handling in C-2 /* Input values are accepted from the user into the array ary[10]*/ #include <stdio.h> void main() { int ary[10]; int i, total, high; for(i=0; i<10; i++) { printf(“ Enter value: %d : ”, i+1); scanf(“%d”,&ary[i]); } /* Displays highest of the entered values */ high = ary[0]; for(i=1; i<10; i++) { if(ary[i] > high) high = ary[i]; } printf(“Highest value entered was %d”, high); /* prints average of values entered for ary[10] */ for(i=0,total=0; i<10; i++) total = total + ary[i]; printf(“The average of the elements of ary is %d”,total/i); }
Array Initialization ,[object Object],[object Object],[object Object],#include <stdio.h> void main() {   char alpha[26];   int i, j;   for(i=65,j=0; i<91; i++,j++)   {   alpha[j] = i; printf(“The character now assigned is %c ”, alpha[j]);   }   getchar(); }
Strings/Character Arrays-1 ,[object Object],[object Object],[object Object],#include <stdio.h> void main() { char ary[5]; int i; printf(“ Enter string : “); scanf(“%s”,ary);  printf(“ The string is %s ”, ary); for (i=0; i<5; i++) printf(“%d”, ary[i]); }
Strings/Character Arrays-2 Output - The input for the above is of 4 characters and the 5 th  character is the null character The above output is for an input of 5 characters
String Functions ,[object Object]
Two-Dimensional Arrays ,[object Object],[object Object],[object Object],[object Object],[object Object]
Initialization of Multidimensional Arrays-1 ,[object Object],[object Object],The result of the above assignment will be as follows :
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Initialization of Multidimensional Arrays-2
Initialization of Multidimensional Arrays-3 The result of the assignment will be as follows : A two - dimensional string array is declared in the following manner : char str_ary[25][80];
Two-Dimensional Array-1 #include <stdio.h> #include <string.h> void main () { int i, n = 0;  int item; char x[10][12]; char temp[12]; clrscr(); printf(“Enter each string on a separate line”); printf(“Type ‘END’ when over ”); /* read in the list of strings */ do { printf(“String %d : ”, n+1); scanf(“%s”, x[n]); } while (strcmp(x[n++], “END”)); /*reorder the list of strings */   contd…. Example
Two-Dimensional Array-2 n = n – 1; for(item=0; item<n-1; ++item) { /* find lowest of remaining strings */ for(i=item+1; i<n; ++i) { if(strcmp (x[item], x[i]) > 0) { /*interchange two stings */ strcpy (temp, x[item]); strcpy (x[item], x[i]); strcpy (x[i], temp);   }   } } /* Display the arranged list of strings */ printf(“Recorded list of strings : ”); for(i = 0; i < n ; ++i) { printf(&quot;String %d is %s&quot;, i+1, x[i]); } } Example

Weitere ähnliche Inhalte

Was ist angesagt? (20)

One dimensional 2
One dimensional 2One dimensional 2
One dimensional 2
 
Array
ArrayArray
Array
 
Array in c
Array in cArray in c
Array in c
 
Chap09
Chap09Chap09
Chap09
 
Arrays
ArraysArrays
Arrays
 
1-D array
1-D array1-D array
1-D array
 
Arrays
ArraysArrays
Arrays
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 
Session 4
Session 4Session 4
Session 4
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
 
arrays in c
arrays in carrays in c
arrays in c
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
 
Two-dimensional array in java
Two-dimensional array in javaTwo-dimensional array in java
Two-dimensional array in java
 
Control statements-Computer programming
Control statements-Computer programmingControl statements-Computer programming
Control statements-Computer programming
 
Array
ArrayArray
Array
 
ARRAY
ARRAYARRAY
ARRAY
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
Arrays
ArraysArrays
Arrays
 

Andere mochten auch

Ossiannilsson langoer 26mars2015
Ossiannilsson langoer 26mars2015Ossiannilsson langoer 26mars2015
Ossiannilsson langoer 26mars2015Ebba Ossiannilsson
 
Innovative Interfaces
Innovative InterfacesInnovative Interfaces
Innovative InterfacesJordan Epp
 
Ossiannilsson130311 openedweek
Ossiannilsson130311 openedweekOssiannilsson130311 openedweek
Ossiannilsson130311 openedweekEbba Ossiannilsson
 
Things That Make You Go Hmmmm
Things That Make You Go HmmmmThings That Make You Go Hmmmm
Things That Make You Go HmmmmChris Waggoner
 
Presentation d4 l-aalborgdk2015
Presentation d4 l-aalborgdk2015Presentation d4 l-aalborgdk2015
Presentation d4 l-aalborgdk2015Ebba Ossiannilsson
 
Ossiannilsson medfak sida_lu2015
Ossiannilsson medfak sida_lu2015Ossiannilsson medfak sida_lu2015
Ossiannilsson medfak sida_lu2015Ebba Ossiannilsson
 
Ngl14 workshop ossiannilsson_creelman_uhlin
Ngl14 workshop ossiannilsson_creelman_uhlinNgl14 workshop ossiannilsson_creelman_uhlin
Ngl14 workshop ossiannilsson_creelman_uhlinEbba Ossiannilsson
 
Taste of Technology
Taste of TechnologyTaste of Technology
Taste of TechnologyJordan Epp
 
Ossiannilsson 140428 icde_langoer_nordicoer
Ossiannilsson 140428 icde_langoer_nordicoerOssiannilsson 140428 icde_langoer_nordicoer
Ossiannilsson 140428 icde_langoer_nordicoerEbba Ossiannilsson
 
פלאפל נוי שמילה
פלאפל נוי שמילהפלאפל נוי שמילה
פלאפל נוי שמילהnoi308
 
Jim Sandrock Resume
Jim Sandrock ResumeJim Sandrock Resume
Jim Sandrock Resumejims2699
 
Agile Project management For Drupal Web Development Projects
Agile Project management For Drupal Web Development ProjectsAgile Project management For Drupal Web Development Projects
Agile Project management For Drupal Web Development ProjectsGregory Heller
 
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15Ebba Ossiannilsson
 
101 Cold Call Tips
101 Cold Call Tips101 Cold Call Tips
101 Cold Call TipsLinda Bishop
 

Andere mochten auch (20)

Eccenca linked data_101 (en)
Eccenca linked data_101 (en)Eccenca linked data_101 (en)
Eccenca linked data_101 (en)
 
Ossiannilsson langoer 26mars2015
Ossiannilsson langoer 26mars2015Ossiannilsson langoer 26mars2015
Ossiannilsson langoer 26mars2015
 
Should I be on Twitter?
Should I be on Twitter?Should I be on Twitter?
Should I be on Twitter?
 
cutting
cuttingcutting
cutting
 
Innovative Interfaces
Innovative InterfacesInnovative Interfaces
Innovative Interfaces
 
Erik Forsberg, Uppsala Bio X
Erik Forsberg, Uppsala Bio XErik Forsberg, Uppsala Bio X
Erik Forsberg, Uppsala Bio X
 
Session 19
Session 19Session 19
Session 19
 
Ossiannilsson130311 openedweek
Ossiannilsson130311 openedweekOssiannilsson130311 openedweek
Ossiannilsson130311 openedweek
 
Things That Make You Go Hmmmm
Things That Make You Go HmmmmThings That Make You Go Hmmmm
Things That Make You Go Hmmmm
 
Presentation d4 l-aalborgdk2015
Presentation d4 l-aalborgdk2015Presentation d4 l-aalborgdk2015
Presentation d4 l-aalborgdk2015
 
Ossiannilsson medfak sida_lu2015
Ossiannilsson medfak sida_lu2015Ossiannilsson medfak sida_lu2015
Ossiannilsson medfak sida_lu2015
 
Ngl14 workshop ossiannilsson_creelman_uhlin
Ngl14 workshop ossiannilsson_creelman_uhlinNgl14 workshop ossiannilsson_creelman_uhlin
Ngl14 workshop ossiannilsson_creelman_uhlin
 
Taste of Technology
Taste of TechnologyTaste of Technology
Taste of Technology
 
Ossiannilsson 140428 icde_langoer_nordicoer
Ossiannilsson 140428 icde_langoer_nordicoerOssiannilsson 140428 icde_langoer_nordicoer
Ossiannilsson 140428 icde_langoer_nordicoer
 
פלאפל נוי שמילה
פלאפל נוי שמילהפלאפל נוי שמילה
פלאפל נוי שמילה
 
1492
14921492
1492
 
Jim Sandrock Resume
Jim Sandrock ResumeJim Sandrock Resume
Jim Sandrock Resume
 
Agile Project management For Drupal Web Development Projects
Agile Project management For Drupal Web Development ProjectsAgile Project management For Drupal Web Development Projects
Agile Project management For Drupal Web Development Projects
 
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15
 
101 Cold Call Tips
101 Cold Call Tips101 Cold Call Tips
101 Cold Call Tips
 

Ähnlich wie Session 7 En

Ähnlich wie Session 7 En (20)

Array&amp;string
Array&amp;stringArray&amp;string
Array&amp;string
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 
02 arrays
02 arrays02 arrays
02 arrays
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
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
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
SlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfSlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdf
 
ARRAYS
ARRAYSARRAYS
ARRAYS
 
Chapter 13.pptx
Chapter 13.pptxChapter 13.pptx
Chapter 13.pptx
 
Array assignment
Array assignmentArray assignment
Array assignment
 
presentation_arrays_1443553113_140676.ppt
presentation_arrays_1443553113_140676.pptpresentation_arrays_1443553113_140676.ppt
presentation_arrays_1443553113_140676.ppt
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
 
array-191103180006.pdf
array-191103180006.pdfarray-191103180006.pdf
array-191103180006.pdf
 
2 arrays
2   arrays2   arrays
2 arrays
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt
 
Module 4- Arrays and Strings
Module 4- Arrays and StringsModule 4- Arrays and Strings
Module 4- Arrays and Strings
 

Mehr von guest91d2b3

Mehr von guest91d2b3 (10)

Session 11
Session 11Session 11
Session 11
 
Session 01
Session 01Session 01
Session 01
 
Session 04 Sua
Session 04 SuaSession 04 Sua
Session 04 Sua
 
Session 02
Session 02Session 02
Session 02
 
Session 17
Session 17Session 17
Session 17
 
Session 06
Session 06Session 06
Session 06
 
Session 09
Session 09Session 09
Session 09
 
Session 13
Session 13Session 13
Session 13
 
Session 15
Session 15Session 15
Session 15
 
Session 21
Session 21Session 21
Session 21
 

Kürzlich hochgeladen

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

Session 7 En

  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Array Handling in C-2 /* Input values are accepted from the user into the array ary[10]*/ #include <stdio.h> void main() { int ary[10]; int i, total, high; for(i=0; i<10; i++) { printf(“ Enter value: %d : ”, i+1); scanf(“%d”,&ary[i]); } /* Displays highest of the entered values */ high = ary[0]; for(i=1; i<10; i++) { if(ary[i] > high) high = ary[i]; } printf(“Highest value entered was %d”, high); /* prints average of values entered for ary[10] */ for(i=0,total=0; i<10; i++) total = total + ary[i]; printf(“The average of the elements of ary is %d”,total/i); }
  • 9.
  • 10.
  • 11. Strings/Character Arrays-2 Output - The input for the above is of 4 characters and the 5 th character is the null character The above output is for an input of 5 characters
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Initialization of Multidimensional Arrays-3 The result of the assignment will be as follows : A two - dimensional string array is declared in the following manner : char str_ary[25][80];
  • 17. Two-Dimensional Array-1 #include <stdio.h> #include <string.h> void main () { int i, n = 0; int item; char x[10][12]; char temp[12]; clrscr(); printf(“Enter each string on a separate line”); printf(“Type ‘END’ when over ”); /* read in the list of strings */ do { printf(“String %d : ”, n+1); scanf(“%s”, x[n]); } while (strcmp(x[n++], “END”)); /*reorder the list of strings */ contd…. Example
  • 18. Two-Dimensional Array-2 n = n – 1; for(item=0; item<n-1; ++item) { /* find lowest of remaining strings */ for(i=item+1; i<n; ++i) { if(strcmp (x[item], x[i]) > 0) { /*interchange two stings */ strcpy (temp, x[item]); strcpy (x[item], x[i]); strcpy (x[i], temp); } } } /* Display the arranged list of strings */ printf(“Recorded list of strings : ”); for(i = 0; i < n ; ++i) { printf(&quot;String %d is %s&quot;, i+1, x[i]); } } Example