I am getting confused with a simple program of multiple if-else in c++. The code
is given below.
include<iostream.h>
void main()
{
int i;
cout<<"Enter the number:";
if(i==1)
{
cout<<"Sunday";
}
if(i==2)
{
cout<<"Monday";
}
else
{
cout<<" invalid input";
}
}
When I try to run this code ,the output shows this.
Enter the number:1
Sunday invalid key
So my question is why the output executing the Else part though the output is True..? Please help me . Thank You