The following is my code:
#include <iostream>
using namespace std;
int main() {
int num;
cout<<"Enter a number: ";
cin>>num;
cout<<"The number is: "<<num;
return 0;
}
If I enter a character or a string instead of an integer on the prompt for cin>>num, the value of num is returned as 0 everytime. Is it because it has been implemented that way in C++ or am I missing some trivial concept? Any answer would be of great help.