Closed Thread
Results 1 to 9 of 9

Thread: ASC II code

  1. #1
    p4thetic is offline Newbie
    Join Date
    Jan 2010
    Posts
    1
    Rep Power
    0

    Unhappy ASC II code

    i m having a problm in writing a program that takes a character from the user and displays whether the character entered is uppercase or a lower case or a symbol.. plx help..

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    QuackWare is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    95
    Rep Power
    8

    Re: ASC II code

    You can take the character from the user then cast it to an int. That will give its ASCII value which you can use a table to look up. Something like this:

    Code:
    char c = Console.ReadLine();
    int asciiValue = (int)c;
    //Then use if statements to check the value.

  4. #3
    JewFro297's Avatar
    JewFro297 is offline Programming Professional
    Join Date
    Jan 2010
    Location
    New York
    Posts
    226
    Rep Power
    0

    Re: ASC II code

    so it be like
    Code:
    if(c <=90 && c >= 60){
         //code if uppercase }
         else if(c <= 122 && c >= 97){
         //code if lowercase}
         else {
         //code if symbol or number}
         //code
    thats C++ Pseudocode but i'm sure its similar in C if thats what you are using
    Yea Dat's right.
    Apple sucks

  5. #4
    lobo521 is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    57
    Rep Power
    8

    Re: ASC II code

    if i understand corectly this sample should help. Without ascii.
    Code:
    using System;
    using System.Threading;
    
    namespace ConsoleApplication1
    {
    	class Program
    	{
    		static void Main()
    		{
    			while (true)
    			{
    				while (!Console.KeyAvailable)
    					Thread.Sleep(250);
    
    				var read = Console.ReadKey(true).KeyChar.ToString();
    				if (IsExitKey(read))
    					return;
    
    				if (IsUpperCase(read))
    					Console.WriteLine("upper");
    				else
    					Console.WriteLine("lower");
    			}
    		}
    
    		private static bool IsExitKey(string read)
    		{
    			return read.ToUpper() == "X";
    		}
    
    		private static bool IsUpperCase(string read)
    		{
    			return read.ToUpper() == read;
    		}
    	}
    }

  6. #5
    JewFro297's Avatar
    JewFro297 is offline Programming Professional
    Join Date
    Jan 2010
    Location
    New York
    Posts
    226
    Rep Power
    0

    Re: ASC II code

    wow I didn't know C# was that different, it kinda reminds me of java
    Yea Dat's right.
    Apple sucks

  7. #6
    QuackWare is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    95
    Rep Power
    8

    Re: ASC II code

    Quote Originally Posted by JewFro297 View Post
    wow I didn't know C# was that different, it kinda reminds me of java
    Yeah it's very similar to java in many ways (syntax etc.) but is also much more powerful and I think easier to use because of the great Visual Studio IDE.

  8. #7
    JewFro297's Avatar
    JewFro297 is offline Programming Professional
    Join Date
    Jan 2010
    Location
    New York
    Posts
    226
    Rep Power
    0

    Re: ASC II code

    too bad it's not portable or i might give it a shot.
    Yea Dat's right.
    Apple sucks

  9. #8
    semprance is offline Programmer
    Join Date
    Jan 2010
    Posts
    126
    Rep Power
    0

    Re: ASC II code

    Quote Originally Posted by JewFro297 View Post
    too bad it's not portable or i might give it a shot.
    Two cheers for Mono :-)

    Main Page - Mono

  10. #9
    JewFro297's Avatar
    JewFro297 is offline Programming Professional
    Join Date
    Jan 2010
    Location
    New York
    Posts
    226
    Rep Power
    0

    Re: ASC II code

    Nice, maybe someday i'll give it a shot. but for now I'm too lazy.
    Yea Dat's right.
    Apple sucks

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem in a href location from php code to html code
    By newphpcoder in forum PHP Development
    Replies: 5
    Last Post: 05-13-2011, 02:03 PM
  2. how to make a bar code reader program in VB 2008 please send me the code
    By tontonskie in forum Visual Basic Programming
    Replies: 1
    Last Post: 11-15-2010, 12:58 AM
  3. add code for font size under php echo code
    By newphpcoder in forum PHP Development
    Replies: 2
    Last Post: 11-10-2010, 11:03 PM
  4. Code: Capture Code from USB Camera
    By MrNobody in forum Visual Basic Tutorials
    Replies: 71
    Last Post: 08-14-2009, 08:59 AM
  5. Code: Capture Code from USB Camera
    By MrNobody in forum Tutorials
    Replies: 5
    Last Post: 09-08-2007, 06:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts