Powered By Blogger

Thursday 26 March 2020

How to print a word or sentence inside double quotation(i.e " ") in 'C' programming

Welcome viewers to this new blog............

Today,we will print any word or sentence inside double quote using 'printf' function in 'c' programming.


Printing sentence within double quotes


As we all already know, how to print any word or sentence or value using "printf" function in 'c' programming.

for example, if we want to print a sentence: To Infinity & Beyond
then, we write: 
                          printf("To Infinity & Beyond");

Output:  To Infinity & Beyond


But have we ever tried to print it inside double quotation(" ") to make them look better.

If you simply want to write it in the 'printf' function, then it will show you an error.

for example:
                     printf(""To Infinity & Beyond"");

Output: (no output)
You should get an error.

Error Message


So, to print any word or sentence inside the double quotation, we need to write the program in the following way:

                                   printf("\"To Infinity & Beyond\"");

Writing the printf function to print double quote


Output:     "To Infinity & Beyond"

Output Window


So, we need to use (\") before the starting of the word or sentence and again one more(\") after the completion of the sentence.

So, that is the simple method by which you can print any word or sentence inside double quotation using 'printf' function in 'c' programming.

Hope, this helps you. Thank you very much for reading my blog. Do comment and share if this helps you. Thank you.

No comments:

Post a Comment

Can we use pointers without specifying the data type of the pointer?

Void Pointer Yes, we can use pointers without specifying the data type of the pointers. But remember at the end of the programming, wh...