I have problem in getting outputs
plz give me suggetion or correct error if any and make it working.......
plz help.........

there is no error........in this program.........when i compiled.

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdio>
#define IS_STRING 1
#define IS_CHARACTER 2
#define IS_INTEGER 3
#define IS_FLOAT 4
//using std::cout;
//using std::cin;
//using std::endl;
using namespace std;
int main(void)
{
string s;
cout<<"Input a string/character/number:\n";
cin>>s;
short int input_type=0;
int x;
bool DotReached=false;
if(s.length()==1 && (s[0]>'9' || s[0]<'0'))
{
input_type=IS_CHARACTER;
cout<< "its a char";
}
else
for(x=0;x<s.length();x++)
{
if((s[x]>'9' || s[x]<'0') && s[x]!='.')
{
input_type=IS_STRING; break;
cout<<" Its an integer ";
}
else if(s[x]=='.')
{if(!DotReached) DotReached= true; else
 {
 input_type=IS_STRING; 
 cout<<"ITs a Float";
 break;
 }
}
}
cin.get();
cin.get();
return 0;
}
for(x=0;x<s.length();x++)
{
    if((s[x]>'9' || s[x]<'0') && s[x]!='.')
   {
   input_type=IS_STRING; break;
   cout<<" Its an integer ";
   }

   else if(s[x]=='.')
  {
   if(!DotReached) DotReached= true; else
   {
   input_type=IS_STRING; 
   cout<<"ITs a Float";
   break;
   }
 }
}

Line 6:
How do you want the program to output "It's an integer" when there's a "break;" before it?
You should output "It's a string" and not "It's an integer" if the input_type is IS_STRING.

Line 14:
Again, it's a string, not a floating-point number.

If you want to determine the input type after you know it's not a char/string (if input_type==0, which is its initial value), you should just check if DotReached returns true or false, because you already know it's a number:

if(input_type==0) // the initial value - meaning no type is determined yet
   {
   if(DotReached) input_type=IS_FLOAT;
   else input_type=IS_INTEGER;
   }

Cool i corrected it ......
thanks Mr Unbeatable()
It works but Also Say Its integer
when i enter Floating

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdio>
#define IS_STRING 1
#define IS_CHARACTER 2
#define IS_INTEGER 3
#define IS_FLOAT 4
//using std::cout;
//using std::cin;
//using std::endl;
using namespace std;
int main(void)
{
string s;
cout<<"Input a string/character/number:\n";
cin>>s;
short int input_type=0;
int x;
bool DotReached=false;
if(s.length()==1 && (s[0]>'9' || s[0]<'0'))
{
input_type=IS_CHARACTER;
cout<< "its a char";
}
else
for(x=0;x<s.length();x++)
{
if((s[x]>'9' || s[x]<'0') && s[x]!='.')
{
input_type=IS_STRING;
cout<<" ITs an String ";
break;
}
else if(input_type==0) 
  {
    if(DotReached) 
    {
     input_type=IS_FLOAT;
     cout<<"Its a Floating Point Value";
     break; 
      }
   else
   {
    input_type=IS_INTEGER;
    cout<<"Its an Integer";
    break;
   }
   }
}
cin.get();
cin.get();
cin.get();
return 0;
}

Need help for this Part

Wats wrong ??

it shows Int For float.............

You have a few errors:
Firstly, the if(input_value==0) ..... should be OUTSIDE the 'for' loop, because you want to check what kind of number the input is after you know it isn't a string nor a char.
Therefore you need to end the loop before this 'if' and remove the 'else' before it.
Secondly, in lines 38-39, the type is IS_STRING, because a number can't have more than a single dot.
Now just return the code you've put in the comments. It's necessary!
Lastly, you don't need the break; in lines 49 and 55, as they're not supposed to be in a loop

I think i corrected mistakes you have mentioned earlier........

Plz Now Say wats the Problem.........

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdio>
#define IS_STRING 1
#define IS_CHARACTER 2
#define IS_INTEGER 3
#define IS_FLOAT 4
//using std::cout;
//using std::cin;
//using std::endl;
using namespace std;
int main(void)
{
string s;
cout<<"Input a string/character/number:\n";
cin>>s;
short int input_type=0;
int x;
bool DotReached=false;
if(s.length()==1 && (s[0]>'9' || s[0]<'0'))
{
input_type=IS_CHARACTER;
cout<< "its a char";
}
else
for(x=0;x<s.length();x++)
{
  if((s[x]>'9' || s[x]<'0') && s[x]!='.')
    {
     input_type=IS_STRING;
     cout<<" ITs an String ";
     break;
     }
}
//else 
if(input_type==0)
   {
    if(DotReached) 
     {
     input_type=IS_FLOAT;
     cout<<"Its a Floating Point Value";
     //break; 
     }
   else
     {
    input_type=IS_INTEGER;
    cout<<"Its an Integer";
     //break;
     }
   }
cin.get();
cin.get();
cin.get();
return 0;
}

That's because you removed this piece of code from your code:

else if(s[x]=='.')
{
   if(!DotReached) DotReached= true;

   else
   {
   input_type=IS_FLOAT; 
   cout<<"ITs a Float";
   break;
   }
}
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdio>
#define IS_STRING 1
#define IS_CHARACTER 2
#define IS_INTEGER 3
#define IS_FLOAT 4
//using std::cout;
//using std::cin;
//using std::endl;
using namespace std;
int main(void)
{
string s;
cout<<"Input a string/character/number:\n";
cin>>s;
short int input_type=0;
int x;
bool DotReached=false;
if(s.length()==1 && (s[0]>'9' || s[0]<'0'))
{
input_type=IS_CHARACTER;
cout<< "its a char";
}
else
for(x=0;x<s.length();x++)
{
  if((s[x]>'9' || s[x]<'0') && s[x]!='.')
   {
     input_type=IS_STRING;
     cout<<" ITs an String ";
     break;
    }
     else if(s[x]=='.')
     {
     if(!DotReached) DotReached= true; 
     else
     {
     input_type=IS_FLOAT; 
     cout<<"Its a flt";
     break;
     }
    //else 
if(input_type==0) // the initial value - meaning no type is determined yet
   {
    if(DotReached) 
     {
     input_type=IS_FLOAT;
     cout<<"Its a Floating Point Value";
     //break; 
     }
   else
     {
    input_type=IS_INTEGER;
    cout<<"Its an Integer";
     //break;
     }
   }
cin.get();
cin.get();
cin.get();
return 0;
}
}
}

IS THIS SO ?????/
MENTION THE LINE IN HERE SIR
I CANT GET IT ....SIR

CAN YOU PLZ FILL WAT TO BE ADDED ........
PLZ.........

Lines 40-41 - it's a STRING, not a float. I've never heard of a number with two decimal dots.
Also, you didn't end the 'for' loop before the input_type check.
You can see it yourself.

COOL IT WORKS
I GOTTCHA

THNKS MAN

UR A KIND FULL PERSON MAN
NOW I AM HAPPY
Great job..........Mr.Unbeatable()..........

THAnks Mr.

heres the working Code

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdio>
#define IS_STRING 1
#define IS_CHARACTER 2
#define IS_INTEGER 3
#define IS_FLOAT 4
//using std::cout;
//using std::cin;
//using std::endl;
using namespace std;
int main(void)
{
 string s;
 cout<<"Input a string/character/number:\n";
 cin>>s;
 short int input_type=0;
 int x;
 bool DotReached=false;
 if(s.length()==1 && (s[0]>'9' || s[0]<'0'))
 {
 input_type=IS_CHARACTER;
 cout<< "its a char";
 }
 else
 for(x=0;x<s.length();x++)
  {
   if((s[x]>'9' || s[x]<'0') && s[x]!='.')
    {
      input_type=IS_STRING;
      cout<<" ITs an String ";
      break;
    }
   else if(s[x]=='.')
    {
     if(!DotReached)
      { 
       DotReached= true; 
      }
   else
     {
      input_type=IS_STRING; 
      cout<<"Its a flt";
      break;
     }
   }
}
    //else 
if(input_type==0) // the initial value - meaning no type is determined yet
   {
    if(DotReached) 
     {
     input_type=IS_FLOAT;
     cout<<"Its a Floating Point Value";
     //break; 
     }
   else
     {
    input_type=IS_INTEGER;
    cout<<"Its an Integer";
     //break;
     }
   }
cin.get();
cin.get();
cin.get();
return 0;
}
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.