Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / The 3rd PPT in this unit lists this example program when explaining the issue of uninitialized variables in C/C++

The 3rd PPT in this unit lists this example program when explaining the issue of uninitialized variables in C/C++

Computer Science

The 3rd PPT in this unit lists this example program when explaining the issue of uninitialized variables in C/C++. In theory the program should return a junk value due to the uninitialized local variable a in adder(). However, it will return 42. Why is that?

 

int adder() {
   int a;
   return a + 2;
}
int assign() {
   int y = 40;
   return y;
}
int main() {
   int x;
   assign();
   x = adder();
   return x;
}

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE