Question
Debugging: When I ran this program it printed 19. #include void main(){ int i, a[5]={1,2,3,4,5},sum; sum = 0; for(i=1; i
Debugging:
When I ran this program it printed 19.
#include
void main(){
int i, a[5]={1,2,3,4,5},sum;
sum = 0;
for(i=1; i<=5; i++)
sum+= a[i]
cout< } This program compiled and ran but printed 19. grrrr. a. The programmer expected the program to print 15. Why? ANS: b. But there is a bug in the code that would have precluded this. What is the bug? ANS: c. What must be going on to cause this output, i.e. what value must be where in memory (for whatever reason, thats not your problem now) to cause the program to print 19? ans:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started