Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

array of chars containing a string ????? can't get it right....

ebjorkebjork caMember Posts: 2

Hi guys it's my first programming class I really like it but don't have as much time as I would like to study it, I can't figure this one out please help.

Assume that word is an array of chars containing a string . Write a statement to display the message "Today's Word-Of-The-Day is: " followed by the value of word on standard output .

Comments

  • ebjorkebjork caMember Posts: 2

    I know it should be something like printf(" ", word);

    have no idea what goes between the parenthesis though I tried %s, that didn't work then I tried Today's %s-Of-The-Day is

  • WiserWiser IsraelMember Posts: 6

    Hey, not sure I got you but you can do it in these two ways:

    The first way sets a String to be the word of the day,
    The second way uses an array of chars.

    In the array what I did is just go over each char and print it to the console.
    Hope that's what you meant.

    Good luck!

    String myWordAsString = "Apple";
    char[] myWordAsChars = { 'B', 'a', 'n', 'a', 'n', 'a'};
    
    Console.WriteLine("Today's Word-Of-The-Day is: " + myWordAsString);
    
    Console.Write("Today's Second Word-Of-The-Day is: ");
    foreach (char i in myWordAsChars){
           Console.Write(i);
    }
    
Sign In or Register to comment.