how do i get and int. to accept only 2 numbers
Printable View
how do i get and int. to accept only 2 numbers
Tell us about your systems configuration first.
Your platform and compiler.
I'm not sure what you mean by this, but if you mean the user enters something like 3956 and you want the int to take 39, here's one way to do it:
[code]
cout<<"Enter an integer: ";
int num;
cin>>num;
while(num>=100)
{
num/=10;
}
cout<<"The first two digits of your integer are: "<<num<<endl;