How can we check the data type of a variable in c++ during a program as we already know the data but our program shud tell us data type we are using

Here you go, it's actually quite easy

#include <iostream>
#include <typeinfo>  // Needed for the typeid
using namespace std;

int main()
{
int variable = 100;
cout<<"The variable type is: "<<typeid(variable).name()<<endl;
// pause or something
return 0;
}

Output:
The variable type is: int

If you want to learn more about the subject, then look for the Run-time type information (RTTI) on Google.

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.