Output JBL in Block Letters with C Programming

AI Thread Summary
The discussion focuses on writing a C program to output the initials "JBL" in block letters. The user initially struggles with formatting, as the output does not align correctly after the first line due to missing newline characters. They learn that adding the newline character '\n' in the printf statements can resolve the issue. Additionally, the user discovers that using tabs can affect spacing, leading to misalignment in the output. Overall, the conversation emphasizes the importance of proper formatting in C programming for desired output.
jaydnul
Messages
558
Reaction score
15
All i have to do is write a program that will output my initials (JBL) in block letters.

This is what i have done:

Code:
#include <stdio.h>
void main()
{
printf("	 JJJJJJ  BBBBBBBB  LLL");
printf("	   JJ     BB    BB    LLL");
printf("	   JJ    BBBBBBB    LLL");
printf("	   JJ    BB    BB     LLL");
printf("      JJ JJ     BB    BB    LLLLLLLL");
printf("	JJJJJ    BBBBBBBB  LLLLLLLL");
}

Now this is wrong of course. When i execute, it will print the top line with the correct number of spaces, but after the first LLL it just goes wack. I assume it is because i am not telling it when to start a new line, right? If so, how do i do that? Also, could i just use 1 printf statement instead of 6?
Thanks
 
Last edited by a moderator:
Physics news on Phys.org
The newline character '\n' should be added inside the "" of the printf string:

printf(" This is a line of text.\n");
 
ahh perfect. Thank you. another problem i was having was i didn't know tab would act as a single space, so it was printing all messed up. Got it now. Thanks SteamKing
 

Similar threads

Replies
3
Views
1K
Replies
1
Views
10K
Replies
3
Views
1K
Replies
9
Views
4K
Replies
4
Views
1K
Replies
5
Views
2K
Back
Top