Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   c question (http://www.go4expert.com/forums/c-question-t3318/)

pradeepjob 9Mar2007 00:36

c question
 
can u print a statement without using a semi colon?
a.Yes
b.No
c.Depends on the compiler

shabbir 9Mar2007 10:19

Re: c question
 
Yes you can.
Code:

main()
{
  if(printf("Print whatever you want here."))
  {
  }
}

This should generate one warning of main not returning anything but its not any error.

DaWei 9Mar2007 18:27

Re: c question
 
I realize your question says, "C compiler", but just for information purposes, a C++ compiler has different requirements. In a standards-compliant C++ compiler, failing to declare the return type of main will generate an error. That return type should properly be "int". Leaving off the return statement will not generate an error in a compliant C++ compiler; the compiler is required to provide it behind the scenes.

All this has nothing to do with the semicolon question, of course. It's amazing how much logic one can put in an expression for an "if" or "while" construct.

wrecker 4Apr2007 01:33

Re: c question
 
Another way to do it is using conditional operators. or ?:..... i hope that you would find satisfactory example.... if you do not know refer this code but its rough....
(x>y)?(printf("\n\n X is greater than Y")):(printf("\n\n Y is greater than X"));

wrecker 4Apr2007 01:34

Re: c question
 
Another way to do it is using conditional operators. or ?:..... i hope that you would find satisfactory example.... if you do not know refer this code but its rough....
(x>y)?(printf("\n\n X is greater than Y")):(printf("\n\n Y is greater than X"));
use smilie as ':'.....

DaWei 4Apr2007 02:18

Re: c question
 
You can prevent smilies (which will be common in C/C++code) by clicking "Go Advanced" and checking the "Disable smilies in text" box....

shabbir 4Apr2007 09:05

Re: c question
 
Quote:

Originally Posted by wrecker
use smilie as ':'.....

Nope its :(

Quote:

Originally Posted by DaWei
You can prevent smilies (which will be common in C/C++code) by clicking "Go Advanced" and checking the "Disable smilies in text" box....

Or you can wrap the code tags around.
Code:

(x>y)?(printf("\n\n X is greater than Y")):(printf("\n\n Y is greater than X"));

wrecker 4Apr2007 10:25

Re: c question
 
Thanks for suggestion. Was unaware of this. WOuld surely keep in mind while posting next time.....
- Wrecker

gjkalaj 2May2007 18:25

Re: c question
 
Hello everybody..
Maybe this request is not related with this section but however I want to ask U if possibly somebody knows... and the question is:

Its about the Graphs as data structures in C programming implementing with adjacency matrix or list or stack (same)

I want to ask if someone knows how is the CODE or Algorithm for solving problem that is related with INTERSECTION OF TWO GRAPHS(I said as a data structure)

If someone knows THNX
If someone doesn know another THNX :))

shabbir 2May2007 20:38

Re: c question
 
gjkalaj, try creating a separate thread for the query with a suitable heading as that will make your query more visible and also help others when searching for something similar.


All times are GMT +5.5. The time now is 05:00.