ysr shk
ysr shk
Branch Unspecified
29 Apr 2012

Is it possible to print something in 'C' without semicolon

Hello friends,
One of my friend asked me that is it possible to print something in 'C' without semicolon.

I had tried more things like turnary operators,MACROs.I cant succeed.
But as you any statement in C will terminate with semicolon so I failed.

Is there any way to print in C without using semicolon?

Thanking You.
nareshkumar6539

nareshkumar6539

Branch Unspecified
6 years ago
Yes it is possible.If you want to print something on console with out using semicolon then write printf() statement in if clause as a condition.
main()
{
if(printf("computer science engineering"))

}
if you execute the above program it will display computer science engineering as output
ysr shk

ysr shk

Branch Unspecified
6 years ago
nareshkumar6539

thaNx it is really useful for me.
Ankita Katdare

Ankita Katdare

Computer Science
6 years ago
Hi,

Could you check if either of these work?

1.
#include <stdio.h>
int main(int argc, char *argv[static printf("Hello World\n"), 0]){}

2.
int main(int argc, char **argv){if (printf("Hello world!\n")) {}}
ysr shk

ysr shk

Branch Unspecified
6 years ago
AbraKaDabra
hey ur first way not works

and second way is same as nareshkumar6539

Share this content on your social channels -

Only logged in users can reply.