0

Here i have problem with ctype.h library .I think i use correctly,but i ahve an error on it.
This is the code.

#include<iostream>
#include <ctype.h>
using namespace std;
int main(){
	char letter;
	int num;
	int isdigit(int letter);
	int  isupper (int letter);
	int islower( int letter);
	int small=0;
	int capital=0;
	int number=0;
	int special=0;

	 cout<<"Enter any number and letter you like,'+'means   exit";
	 /* use if statement to help user to count how many times s/he enter letter*/
   for(int i=0;i<=5;i++)  //any number greater than one
	{     //start while here
	

	  cin>>letter; //user enter a number
	  if (letter==isdigit(letter))
		  number++;
	  if(letter==isupper(letter))
		capital++;  //counting capital letter
	  else  if(letter==islower(letter))
		  small++;  //in case enter small, letter counting small letter
	  
	  else if(letter!=isupper(letter) && letter!=islower(letter) && num!=isdigit(num))
		  special++;  /*if the user enter a sepcial                                    chraecter*/

   }
	  
	
	

      cout<<number<<endl<<small<<endl<<capital<<endl<<special;
return 0;
}
2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by computer engW
0

'is' functions return a boolean result ('is' true or isn't true, otherwise known as false).

So

if ( isdigit(letter) ) {
  number++;
}

Oh, and in C++, use #include <cctype>

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.