AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: xianfeng — October 6, 2006
    -1 votes
      + -

    Lowercase(c1) to uppercase(c2):
    c2= c1 +’a'-’A';

  2. Submitted By: octav_timofte — October 6, 2006
    +5 votes
      + -

    Lower case to upper case is correctly like this:

    if (islower(c))
    c = c-’a'+’A’

    Upper case to lower case is
    if (isuuper(c))
    c = c-’A'+’a’

    Note. The condition tested is to prevent the translation of non-alphabetic characters.

  3. Submitted By: doshimun — October 6, 2006
    +3 votes
      + -

    Instead how about this way:

    void ToUpper(char * S)
    {
    while (*S!=0)
    {
    *S=(*S>=’a’ && *S<=’z')?(*S-’a'+’A'):*S;
    S++;
    }
    }

  4. Submitted By: shanu_eternal — October 6, 2006
    +1 votes
      + -

    use the ascii set.
    the lower case and upper case differ only on one bit..just toggle that bit.

  5. Submitted By: Gary Chen — October 6, 2006
    +7 votes
      + -

    Doesn’t matter which way the character is to be converted, just flip one bit.

    ConvertChar( char *c )
    {
    *c = (*c) ^ (’A’ - ‘a’);
    }

  6. Submitted By: gman — October 6, 2006
    -1 votes
      + -

    This should do it ( I have tested it):

    char c;
    c=c-(’a'-’A');

  7. Submitted By: gorion — October 6, 2006
    +1 votes
      + -

    Try this

    void ToUpper(char *str)
    {
    // do error checking. This impresses people :-)
    if (!str)
    return;

    for (int i = 0; str[i]; i++)
    {
    if (str[i] >= ‘a’ && str[i] <= ‘z’)
    str[i] = str[i] - 32;
    }
    }

    this one is really straightforward once you realize that ‘A’ and ‘a’ are 32 apart. The ASCII table was designed so that major groups of characters were 32 apart, i.e., 32 control chars, then 32 upper case + numbers + symbols, then 32 lowercase + more symbols, …

    Unfortunately, you can’t just toggle bit 32, since that would INVERT the case of the string. The problem says to convert a string to upper case.

  8. Submitted By: Weimin — May 26, 2007
    not yet rated
      + -

    int main () {

    char str[ ]={’s’,'t’,'r’,'i’,'n’,'g’,”};
    char * ptr;
    ptr=str;

    while (*ptr!=”)
    {

    printf(”%c”,*ptr++);

    }

    ptr=str;

    while (*ptr!=”)
    {
    *ptr=*ptr-0×20;
    printf(”%c”,*ptr++);

    }

    return 0;
    }

  9. Submitted By: Kevin Choong — March 4, 2008
    +1 votes
      + -

    void ConvertChar( char *c )
    {
    *c = (*c) ^ (’a'-’A');
    }

  10. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.