#include<iostream>
using namespace std;
int i;
void main()
{
i=10;
cout<<"\n"<<"in main(), the value of i is:"<<i;
f();
cout<<"\n"<<" back in main(),the value of i is:"<<i;
}
void f()
{
cout<<"\n"<<"in f(),the value of i is:"<<i;
i=20;
}
unable to compile this program. compiler give void main error please help
#include<iostream>
usingnamespace std;
void f()
{
int i = 20;
cout << "\n" << "in f(),the value of i is:" << i;
}
int main()
{
int i = 10;
cout << "\n" << "in main(), the value of i is:" << i;
f();
cout << "\n" << " back in main(),the value of i is:" << i;
return 0;
}
Tried Leaving everything as similar to original as possible
void main() // <--- Change this to int main()
Also you would need to put void f() above int main (), so main() knows what f() does
P.S. use source code in format so its easier to read your code! Thanks!