CPP program to check that the entered character is small, capital or a special character

C++/CPP program to check that the entered character is small, capital or a special character?

Logic of the program

If in the program, Ascii_value_Variable>=97 && Ascii_value_Variable<=122, then the character is small.

If in the program, Ascii_value_Variable>=65 && Ascii_value_Variable<=90, then the character is capital.

If in the program, Ascii_value_Variable>=0 && Ascii_value_Variable>=47 || Ascii_value_Variable>=54 && Ascii_value_Variable<=64 || Ascii_value_Variable>=91 && Ascii_value_Variable<=96 || Ascii_value_Variable>=123 && Ascii_value_Variable<=127,then the character is a special character.

If in the program, Ascii_value_Variable>=47 && Ascii_value_Variable<=57,then it means that you have entered a digit.

Program

#include<iostream>
using namespace std;
int main()
{
  char v_charac_varible;
  cout<<"Enter a v_charac_varible =  ";
    cin>>v_charac_varible;

  int Ascii_value_Variable=v_charac_varible;
  cout<<"The ASCII value  of "<<v_charac_varible<<
        " is "<<Ascii_value_Variable;

  if(Ascii_value_Variable>=97 && Ascii_value_Variable<=122)
  {
    cout<<"\nYou have entered a small letter";
  }
  else if(Ascii_value_Variable>=65 && Ascii_value_Variable<=90)
  {
    cout<<"\nYou have entered a capital letter";
  }

    else if (Ascii_value_Variable>=0 && Ascii_value_Variable>=47
      || Ascii_value_Variable>=54 && Ascii_value_Variable<=64
      || Ascii_value_Variable>=91 && Ascii_value_Variable<=96 
      || Ascii_value_Variable>=123 && Ascii_value_Variable<=127)
  {
    cout<<"\nYou have entered a special v_charac_varible";
  }
else if (Ascii_value_Variable>=47 && Ascii_value_Variable<=57)
  {
    cout<<"\nYou have entered a digit ";
  }
return 0;
}

.

Fazal Rehman Shamil Click Here to Know More
Instructor, Researcher, Blogger, SEO Expert, Poet and Publisher of International Journal Of Software, Technology & Science ISSN : 2616 - 5325
Dear Professors and Resarchers!You are welome to Cite these tutorials in your research or slides etc. Please don't forget to mention the reference of website. Copy Paste of text is strcitly forbidden. Images can be reuse because images are protected with watermark.

Leave a Reply

Your email address will not be published. Required fields are marked *