473,765 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing "hello , wolrd" with out using semicolon

Hi,
Can any body tell me how to print "hello,worl d" with out using semicolon

Thanks in advance ..
Bye
Prashanth Badabagni
Nov 14 '05 #1
42 9895
b_*********@hot mail.com (Prashanth Badabagni) writes:
Can any body tell me how to print "hello,worl d" with out using semicolon


"hello,worl d" doesn't contain a semicolon.
Nov 14 '05 #2
Prashanth Badabagni wrote:
Hi,
Can any body tell me how to print "hello,worl d" with out using semicolon


Yes. Now ask someone to help you search the archives at groups.google.c om.
Nov 14 '05 #3
b_*********@hot mail.com (Prashanth Badabagni) wrote in message news:<d1******* *************** ****@posting.go ogle.com>...
Hi,
Can any body tell me how to print "hello,worl d" with out using semicolon

Thanks in advance ..
Bye
Prashanth Badabagni


#include<stdio. h>

void main()
{
if(printf("hell o world\n"))
}
Nov 14 '05 #4
ma********@yaho o.com (madhukar_bm) wrote:
b_*********@hot mail.com (Prashanth Badabagni) wrote in message news:<d1******* *************** ****@posting.go ogle.com>...
Can any body tell me how to print "hello,worl d" with out using semicolon


#include<stdio. h>

void main()
{
if(printf("hell o world\n"))
}


You _did_ compile this, I suppose?

Richard
Nov 14 '05 #5
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

madhukar_bm wrote:
b_*********@hot mail.com (Prashanth Badabagni) wrote in message news:<d1******* *************** ****@posting.go ogle.com>...
Hi,
Can any body tell me how to print "hello,worl d" with out using semicolon

Thanks in advance ..
Bye
Prashanth Badabagni

#include<stdio. h>

Whilst this line, of itself, does not contain a semicolon, it's actions
effectively insert many other lines (some of which /may/ contain semicolons)
into the source code. This is line technically satisfies the OPs requirement,
but operationally may not.

void main()
In a hosted implementation, main() returns int, and must be declared so, unless
an implementation-specific extension is in use. No such extension has been
mentioned, and the OPs question does not specify an unhosted implementation, so
this line is suspect.
{
if(printf("hell o world\n"))
An if() statement requires the inclusion of at least one additional statement,
to be executed when the if() evaluates to true. Your code above is a syntax
error at the very least.

Also, main() returns int. Ensure that int is returned. }


Alternatively, given a C99-compliant compiler for a hosted environment...

int main(void)
{
if (printf("hello, world\n")) {}
}

/*
** In the absence of a prototype, the printf() function is
** assumed to return int and to take as its argument
** a single string. Both of these assumptions are consistant
** with the function declaration found in stdio.h, and thus
** while fragile and technically suspect, is acceptable.
** The absence of the stdio include eliminates the possibility
** of included semicolons, and satisfies the argument against
** the use of an included header in /this/ program.
**
** The if() statement is satisfied by an empty compound statement,
** correcting the previous poster's syntax error.
**
** Finally, as the main() function is defined as returning int, and
** this is specified to be compiled in a C99-compliant compiler for
** a hosted environment, the language environment will ensure that
** an appropriate int value is returned from main() in the absence
** of an explicit value return.
*/

- --
Lew Pitcher
IT Consultant, Enterprise Application Architecture,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFAljs6agV FX4UWr64RAhvyAK CqIs5ZG0a3SOnnz jBhIyVtXgcgqACe PvBS
mcMg7GKVMllpnd7 ezuwi+g4=
=8u1d
-----END PGP SIGNATURE-----
Nov 14 '05 #6
Lew Pitcher wrote:
Alternatively, given a C99-compliant compiler for a hosted environment...

int main(void)
{
if (printf("hello, world\n")) {}
}
No C99-compliant compiler is required to accept this program, since
there is no declaration in scope for printf().
/*
** In the absence of a prototype, the printf() function is
** assumed to return int and to take as its argument
** a single string. Both of these assumptions are consistant
** with the function declaration found in stdio.h, and thus
** while fragile and technically suspect, is acceptable.


No, calling a function that accepts a variable number of arguments
through a function pointer of non-variadic type invokes undefined
behaviour.

6 If the expression that denotes the called function has a type that
does not include a prototype, the integer promotions are performed
on each argument, and arguments that have type float are promoted
to double. [...] If the function is defined with a type that
includes a prototype, and either the prototype ends with an
ellipsis (, ...) or the types of the arguments after promotion
are not compatible with the types of the parameters, the behavior
is undefined. [C99 6.5.2.2]

If you want to rely on an "implicit declaration" (using a C89
compiler), you can use puts() instead.

Jeremy.
Nov 14 '05 #7
Prashanth Badabagni wrote:
Hi,
Can any body tell me how to print "hello,worl d" with out using semicolon

Thanks in advance ..
Bye
Prashanth Badabagni


Besides being a homework candidate question, what useful
application does this suit?

I've never concerned myself with this kind of issue in all
my 30 years of programming.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #8
On Mon, 2 May 2004, Prashanth Badabagni wrote:
Hi,
Can any body tell me how to print "hello,worl d" with out using semicolon


Yes, you go to http://www.google.ca/grphp and search for
"group:comp.lan g.c hello world no semicolon".

--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@ whitehouse.gov
Nov 14 '05 #9

"Prashanth Badabagni" <b_*********@ho tmail.com> wrote in message
news:d1******** *************** ***@posting.goo gle.com...
Hi,
Can any body tell me how to print "hello,worl d" with out using semicolon
Thanks in advance ..
Bye
Prashanth Badabagni


why would you want to?
Allan
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
5580
by: ankursinha | last post by:
Hi, Is it possible to write a C program that prints "Hello World" on screen without having a single semi-colon in the entire program? The extra constraint here is that u r not allowed to use if,while,switch etc. So far,i figured this could be done by insertint the printf statement in main as shown: int main(int argc=printf("Hello world")
51
4144
by: Spidey | last post by:
for(;0;) printf("hello"); even the condition s wrong i get a hello printed on the screen y s this happening
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.