SlideShare una empresa de Scribd logo
1 de 1
z Why would the following code give a compiler error? How might you fix it? void doStuff
const int size) int array(size) 3) Why might you get run nie errors when running the ng function?
How would you fix it? int sum( int arrayll, int size) 1 3 4 int count 0 for( int size; i> 0; --i sive
count array return lo noi count:
Solution
3) in for(int i=size;i>=0;--i) this will create a logical error which will access array out of bound.
replace intilization of i to size-1, this will take exactly the same number of elements as the size
otherwise a garbage value will be included giving the wrong output.
2) we are declaring local array without using it in the function. there is no use of function for just
declaration.

Más contenido relacionado

Más de altonm

Often in science it is helpful to talk about a representative example.docx
Often in science it is helpful to talk about a representative example.docxOften in science it is helpful to talk about a representative example.docx
Often in science it is helpful to talk about a representative example.docx
altonm
 

Más de altonm (16)

Okay- so I understand questions 1- however I don-'t get how to find ou.docx
Okay- so I understand questions 1- however I don-'t get how to find ou.docxOkay- so I understand questions 1- however I don-'t get how to find ou.docx
Okay- so I understand questions 1- however I don-'t get how to find ou.docx
 
ofa fallowing sormally wuma vp faest wee heot in appliod A) water B) w.docx
ofa fallowing sormally wuma vp faest wee heot in appliod A) water B) w.docxofa fallowing sormally wuma vp faest wee heot in appliod A) water B) w.docx
ofa fallowing sormally wuma vp faest wee heot in appliod A) water B) w.docx
 
Often in science it is helpful to talk about a representative example.docx
Often in science it is helpful to talk about a representative example.docxOften in science it is helpful to talk about a representative example.docx
Often in science it is helpful to talk about a representative example.docx
 
Obstacles in EHRs Implementation Discuss the major local- national- an.docx
Obstacles in EHRs Implementation Discuss the major local- national- an.docxObstacles in EHRs Implementation Discuss the major local- national- an.docx
Obstacles in EHRs Implementation Discuss the major local- national- an.docx
 
o be (11) Explain why an object (like a pencil) that is partially subm.docx
o be (11) Explain why an object (like a pencil) that is partially subm.docxo be (11) Explain why an object (like a pencil) that is partially subm.docx
o be (11) Explain why an object (like a pencil) that is partially subm.docx
 
Numerical Analysis- (Matlab) Write a program that computes an integral.docx
Numerical Analysis- (Matlab) Write a program that computes an integral.docxNumerical Analysis- (Matlab) Write a program that computes an integral.docx
Numerical Analysis- (Matlab) Write a program that computes an integral.docx
 
Yvon- an accountant- is charged with negligence by Zesty Sauce- Inc--.docx
Yvon- an accountant- is charged with negligence by Zesty Sauce- Inc--.docxYvon- an accountant- is charged with negligence by Zesty Sauce- Inc--.docx
Yvon- an accountant- is charged with negligence by Zesty Sauce- Inc--.docx
 
Your host has automatically received an IPv6 address working in conjun.docx
Your host has automatically received an IPv6 address working in conjun.docxYour host has automatically received an IPv6 address working in conjun.docx
Your host has automatically received an IPv6 address working in conjun.docx
 
Your community has decided to construct a hazardous waste facility for.docx
Your community has decided to construct a hazardous waste facility for.docxYour community has decided to construct a hazardous waste facility for.docx
Your community has decided to construct a hazardous waste facility for.docx
 
Young Corporation incurred research and development costs of $500-000.docx
Young Corporation incurred research and development costs of $500-000.docxYoung Corporation incurred research and development costs of $500-000.docx
Young Corporation incurred research and development costs of $500-000.docx
 
You work for a small city IT department- and you are reviewing compute.docx
You work for a small city IT department- and you are reviewing compute.docxYou work for a small city IT department- and you are reviewing compute.docx
You work for a small city IT department- and you are reviewing compute.docx
 
Your CEO is from the old school- What steps would you take to entice h.docx
Your CEO is from the old school- What steps would you take to entice h.docxYour CEO is from the old school- What steps would you take to entice h.docx
Your CEO is from the old school- What steps would you take to entice h.docx
 
You work for a small city IT department- and you are providing trainin.docx
You work for a small city IT department- and you are providing trainin.docxYou work for a small city IT department- and you are providing trainin.docx
You work for a small city IT department- and you are providing trainin.docx
 
You work for a small city IT department- and you are reviewing the dif.docx
You work for a small city IT department- and you are reviewing the dif.docxYou work for a small city IT department- and you are reviewing the dif.docx
You work for a small city IT department- and you are reviewing the dif.docx
 
You work for a small city IT department- and you are reviewing compute (1).docx
You work for a small city IT department- and you are reviewing compute (1).docxYou work for a small city IT department- and you are reviewing compute (1).docx
You work for a small city IT department- and you are reviewing compute (1).docx
 
____ is used specifically for the purpose of recording keystrokes or o.docx
____ is used specifically for the purpose of recording keystrokes or o.docx____ is used specifically for the purpose of recording keystrokes or o.docx
____ is used specifically for the purpose of recording keystrokes or o.docx
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Último (20)

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

z Why would the following code give a compiler error- How might you fi.docx

  • 1. z Why would the following code give a compiler error? How might you fix it? void doStuff const int size) int array(size) 3) Why might you get run nie errors when running the ng function? How would you fix it? int sum( int arrayll, int size) 1 3 4 int count 0 for( int size; i> 0; --i sive count array return lo noi count: Solution 3) in for(int i=size;i>=0;--i) this will create a logical error which will access array out of bound. replace intilization of i to size-1, this will take exactly the same number of elements as the size otherwise a garbage value will be included giving the wrong output. 2) we are declaring local array without using it in the function. there is no use of function for just declaration.