1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Computer science assignment. (strings)

  1. Nov 1, 2006 #1
    i need a make a program that prompts the user to enter a string, and for it to identify the uppercase characters and replace each uppercase char with the corresponding lowercase character. it also needs to count the character

    here's what i have so far:

    Code (Text):

    int uppercount,i;

        printf("Please enter characters:\n");

        if(letter[i]>= 'A' && letter[i] <='Z')      
            letter[i] = letter[i] - 'A'+ 'a';
        printf("%c\n", letter);
           printf("The number of uppercase letters entered: %d", uppercount);

    doesn't seem to work as i would like.. what changes should i make?
  2. jcsd
  3. Nov 1, 2006 #2
    Initialize your variables and be aware the the letter in the printf will attempt to print out the address of the array as a character (you need to dereference your array by adding a and put it inside a loop since %c will print (I believe) out one character at a time). You also need some kind of loop to count the uppercase letters.
    Last edited: Nov 1, 2006
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Computer science assignment. (strings)