Write "hello world program" without using any semicolon in C

This question is related to TCS Interview

Editorial / Best Answer

leorius47  

  • Member Since Mar-2008 | Mar 4th, 2008


main()
 {
 if (printf("nHello World"))
  {
  }
}

Showing Answers 1 - 13 of 13 Answers

santosh kumar dara

  • Aug 6th, 2011
 

Yes it is possible writing the sample program to print hello world program without using the semicolon and by using if condition. here is the sample code for doing that

Code
  1. #include<stdio.h>

  2. void main()

  3. {

  4. if(printf("hello world program"))

  5. {

  6.  

  7. }

  8. getch();

  9. }

  10.  

Rahul Jaswal

  • Aug 12th, 2011
 

it will give an error" Macro argument syntax error"
correct ans is :

#define h printf("Hello World)
void main()
{
h;
getch();
}

  Was this answer useful?  Yes

Prem Parashar

  • Aug 13th, 2011
 

Code
  1. #include <stdio.h>

  2. void main()

  3.  {

  4.   if(printf("hello world"))

  5.    {

  6.    }

  7.   }

  Was this answer useful?  Yes

suresh

  • Aug 14th, 2011
 

void main
{
if(printf("hello world"))
{
}
}

  Was this answer useful?  Yes

pradeep prajapat

  • Aug 24th, 2011
 

but this code will not print the output on console...
we have to use getch(); for displaying statement

  Was this answer useful?  Yes

ganapathi

  • Aug 25th, 2011
 

Line 15: error: ""hello world"" may not appear in macro parameter list

  Was this answer useful?  Yes

rajasekhar469@gmail.com

  • Sep 13th, 2011
 

Code
  1. main()

  2. {

  3. while(!printf("hellow world"))

  4. {}

  5. }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions