What is the output of this program (if any)
#include<iostream.h>
using namespace std;
void main()
{
int num=123;
int *p_num;
cout<<"if any"<<"\n";
cout<<num<<"\n";
cout<<&num<<"\n";
cout<<*p_num<<"\n";
cout<<p_num<<"\n";
}
The line "cout<<*p_num" gives an error, because variable p_num need initialization before using cout. The line "cout<<p_num<<"\n"" may work on some compilators and prints "0", but with Microsoft Visual Studio you will get an error on compilation with the message about initialization variable p_num.
Comments
Leave a comment