How to break printf in multiple lines ?
Break long Printf Statement Upto Multiple Lines in C :
Printf statement is used for displaying text,message or output of the program.So question is that “Can a long printf statement be broken up into multiple lines ?” Its answer is Yes we have 3 tricks by which you can break printf upto multiple lines
3 ways of Multiline
- Using “Backward Slash”.
- Using “Double Quotes”
- By Dividing Printf into Many Small Printf’s
Let us Discuss one by one -
1 . Using “Backward Slash”.
#include<stdio.h> void main() { printf("C Programming is \ funny Language "); }
Output :
C Programming is funny Language
Note :
- One printf can be broken into ‘n’ number of lines using “Backslash”
- No need to Close “Double Quotes” after first line.
- Opening Double Quote always on First Line while Closing Double Quote always on Last Line.
2 . Using “Double Quotes”
#include<stdio.h> void main() { printf("C Programming is " "funny Language "); }
Output :
C Programming is funny Language
Note :
- Each Line needs Opening and Closing “Double Quote”.
3 . Break Long Printf in Small PRintf’s
#include<stdio.h> void main() { printf("C Programming is "); printf("funny Language "); }
Output :
C Programming is funny Language