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

ysr shk

ysr shk

@ysr-shk-8AjUTB Oct 18, 2024
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.

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • nareshkumar6539

    nareshkumar6539

    @nareshkumar6539-BKuVbx Apr 23, 2012

    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

    @ysr-shk-8AjUTB Apr 23, 2012

    #-Link-Snipped-#

    thaNx it is really useful for me.
  • Ankita Katdare

    Ankita Katdare

    @abrakadabra Apr 29, 2012

    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

    @ysr-shk-8AjUTB Apr 29, 2012

    #-Link-Snipped-#
    hey ur first way not works

    and second way is same as #-Link-Snipped-#