Go Back   PCMech Forums > Help & Discussion > Software Discussion & Support

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-24-2005, 03:51 PM   #1
Member (7 bit)
 
Join Date: Aug 2003
Location: Hinckley in Leicestershire
Posts: 110
Simple C Program... Help

Edit - Ignore this.. its working now





Hey.. trying to make a program that gets the user to enter a single "character" and then check what it is and print out these messages...

1. "? is an upper case letter" if the character is between 'A' and 'Z'
2. "? is a lower case letter" if the character is between 'a' and 'z'
3. "? is not a letter" otherwise

i've done the first two.. but can't manage number three.. it won't recognise non alphanumeric characters like "~" or ";" etc..

here's my code so far

Quote:
#include
#include "c:\cygwin\csci1401.h"

main()
{
char sinChar;
int isLower, isUpper;

printf("Enter a single character");
sinChar = getChar();

int isLower = sinChar >= 'a' && sinChar <= 'z';
int isUpper = sinChar >= 'A' && sinChar <= 'Z';
if ( isUpper )
{
printf("%c is an upper case letter\n", sinChar);
}

if ( isLower )
{
printf("%c is an lower case letter\n", sinChar);
}

if ( !isLower && !isUpper )
{
printf("%c is not a letter\n", sinChar);
}

}
but the last bit (in bold) won't work

Thanks in advance.
Ben

Last edited by Tiestarian; 10-24-2005 at 04:02 PM.
Tiestarian is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:56 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2