Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialcody carlson
103 Pointshelp
how do i do this problem when i learned how to do this with char on the videos
1 Answer
David Gray
1,029 PointsHi Cody, here's the code for the challenge. You are stating the type of the variable by the first word, 'char' in this case, then you are creating a name for the variable which would be 'alpha' (without quotes) then you are assigning a value to that variable using the = sign. The information on the right of the equals sign is then stored in the variable called 'alpha'. You would repeat this for the 'bravo' variable too.
char alpha = 'a';
char bravo = 'b';
This could also be done like so:
char alpha;
char bravo;
alpha = 'a';
bravo = 'b';
I personally like the first method where you declare and initialise the variables in one line :)
eirikvaa
18,015 Pointseirikvaa
18,015 PointsExactly what are you struggling with? You are asked to declare two variables of type char and assign some value to each of them.