1.

void initialise(){int k = 10;}int main(){int a, b;float marks;a = 20;cout<<"First value="<<a;initialise();b = k + a;cout<<"New value="<<b;}1. Identify the error in the, above code and explain its reasons. 2. Correct the errors

Answer»

1. K is a local variable in the function initialize() – It is not accessible in main()

2. Making the variable K as global we can correct the error.



Discussion

No Comment Found