It's not homework it is just a play.If you have any simmilar tragic like this one with int and character or float then please discuss it here or explain how things happen.Let this thread be informative.
I'm playing with int,floats and type casts but i have found that in following program when i enter the value of first integer as float,it skips out the cout statement that asks for float value,instead it takes the float value frm the decimal number we entered frm the first first input we get from cin.What is going on? i dnt get it if i entered float value then it skips next statement?How and why?How can i get my chance of inputing another float number in that case? Anyone like to explain what happened here?
//IDE: Codeblocks 8.02
#include<iostream>
using namespace std;
int main()
{
int a;
float b;
cout<<"Enter the integer number"<<endl;
cin>>a;
cout<<"\n Enter float number"<<endl;
cin>>b;
cout<<endl;
cout<<a<<endl;
cout<<b<<endl;
system("pause");
exit(0);
}
I have one more Big Question in this case is that "If i want to find out what value is input by user here,before printing it.How can i find out that it's integer or float?"
You can pass your teasing questions here or answer mine,i'm looking for simmilar situations with the code.