C Program to Use Printf(); Function Without The Semicolon


We all know, every statement in C is terminated by semicolon (;). The same apply to printf(); function.

Suppose we are going to print Lightning Code on the screen than statement for it will be printf(“Lightning Code”); but what if we want to print it without the semicolon after printf. Think about it, how can you do it, I know, you know how can but you did’t notice it.

Let me give you a hint, when we use if(); statement to condition something, we never use the semicolon inside the parenthesis. Now I am sure you make it out.

Let’s Have Ah Look at Program ►►

#include<stdio.h>
#include<conio.h>
 
void main()
{
 if(printf("Lightning Code"))
 {
  }
 getch();   
}

That’s It.. There are many things in C Language that we can do cleverly. I’ll tell you about all.

And as same we do this with if, we can also use while(); statement to print anything without the semicolon ; after printf function.

What will happen in the program when we will execute it is that if will check the condition to be true or false inside the parenthesis. While doing so the printf() function will be executed and the output will be print on the screen. 

Advertisements

One thought on “C Program to Use Printf(); Function Without The Semicolon”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s