[ create a new paste ] login | about

Link: http://codepad.org/WJERh4UU    [ raw code | output | fork ]

C, pasted on Jan 24:
#include <stdio.h>
#define isnum(c) ('0' <= c && c <= '9')
#define isupc(c) ('A' <= c && c <= 'Z')
#define islwc(c) ('a' <= c && c <= 'z')

int main(void)
{
	int c;

	printf("Input character: ");
	c = getchar();

#if NUMBER
	if (isnum(c))
	{
		printf("%c is number\n", c);
	}
	else
	{
		printf("%c is not number\n", c);
	}
#elif ALPHABET
	if (isupc(c))
	{
		printf("%c is upper alphabet\n", c);
	}
	else if (islwc(c))
	{
		printf("%c is lower alphabet\n", c);
	}
	else
	{
		printf("%c is not alphabet\n", c);
	}
#endif

	return 0;
}


Output:
1
Input character: 


Create a new paste based on this one


Comments: