Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Objective-C Basics (Retired) Fundamentals of C Arrays

Help

I'm brand new to coding, this is literally the first day learning. I'm stuck on this code challenge and can't seem to get it right. Is there a help function I'm not aware of?

Stone Preston
Stone Preston
42,016 Points

please post teh code you have currently tried

4 Answers

can you post the link

Stone Preston
Stone Preston
42,016 Points

usually the link is on the right side of the page under "Related Content" FYI. depends on if the forum poster created the post from the challenge/quiz/video or not though so its not always there.

The challenge is: Print the results. Your output should look like "letters a b".

Here is the info:

char letters[2]; letters[0] = alpha letters[1] = bravo

My answer is: printf("letters a b %c\n", letters[0]); printf("letters a b %c\n", letters[1]);

I can't figure out what I'm doing wrong..

Stone Preston
Stone Preston
42,016 Points

"Your output should look like "letters a b"." You only need one printf statement, and remember the variables you pass to printf show up in the string where you put the format specifiers when output to the console. Try using

printf("letters %c %c", letters[0], letters[1]);

see how I put the format specifiers where I want the values of the variables to show up?

letters[0] = alpha letters[1] = bravo They should be seperated by ; and should be like this: letters[0]=alpha; letters[1]=bravo;

Print the result. Your result should be like letters a b printf("letters %c %c",letters[0],letters[1]);

My answer is: printf("letters a b %c\n", letters[0]); printf("letters a b %c\n", letters[1]); the editor expects you to write the print statement in one line as shown above...

Declare 2 separate variables of type char named "alpha" and "bravo". Assign the letter 'a' to the variable "alpha" and the letter 'b' to "bravo". char alpha='a'; char bravo='b';

Declare an array of type 'char' called "letters" with a size of 2. Assign the variable "alpha" as the first element of the array "letters". char letters[2]; letters[0]=alpha;

Assign the variable "bravo" as the second element of the array "letters". letters[1]=bravo;

Print the result. Your result should be like letters a b printf("letters %c %c",letters[0],letters[1]);

I hope this was the one you were talking about. Its ok things might seem a little hard . But you will soon start getting into the flow.....

Thank you guys very much.. I figured out what I was doing wrong. I'm sure I'll post again soon. Thanks for being so kind :)