Author |
Message |
jhooper3581
|
Posted: Fri Aug 28, 2009 7:25 am Post subject: Write a simple source code |
|
|
Output: "C++ programming is fun!"
Write a C++ source code that will give the correct output given above |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
A.J

|
Posted: Fri Aug 28, 2009 8:47 am Post subject: RE:Write a simple source code |
|
|
c++: |
#include<iostream>
using namespace std;
int main()
{
cout << "C++ programming is fun!" << endl;
return 0;
}
|
|
|
|
|
|
 |
jhooper3581
|
Posted: Fri Aug 28, 2009 8:50 am Post subject: (No subject) |
|
|
Thanks for the reply! |
|
|
|
|
 |
saltpro15

|
Posted: Fri Aug 28, 2009 11:07 am Post subject: RE:Write a simple source code |
|
|
an alternative
c++: |
#include<cstdio>
main()
{
printf ("C++ Programming is fun!");
return 0;
}
|
|
|
|
|
|
 |
bbi5291
|
Posted: Fri Aug 28, 2009 11:18 am Post subject: Re: Write a simple source code |
|
|
Shortest code contest!
c++: |
#import <cstdio>
main()
{
return puts("C++ programming is fun!"),0;
}
|
|
|
|
|
|
 |
wtd
|
Posted: Fri Aug 28, 2009 11:55 am Post subject: Re: RE:Write a simple source code |
|
|
saltpro15 @ Sat Aug 29, 2009 12:07 am wrote: an alternative
c++: |
#include<cstdio>
main()
{
printf ("C++ Programming is fun!");
return 0;
}
|
No return type for "main" is being bad. Also, if memory serves, the C++ standard says that main implicitly returns zero if no explicit return is coded. |
|
|
|
|
 |
A.J

|
Posted: Fri Aug 28, 2009 1:22 pm Post subject: RE:Write a simple source code |
|
|
How about we open a new thread for an obfuscated code contest? |
|
|
|
|
 |
bbi5291
|
Posted: Fri Aug 28, 2009 1:24 pm Post subject: Re: RE:Write a simple source code |
|
|
wtd @ Fri Aug 28, 2009 11:55 am wrote:
No return type for "main" is being bad. Also, if memory serves, the C++ standard says that main implicitly returns zero if no explicit return is coded.
Fine then.
c++: |
#import <cstdio>
int main()
{
puts("C++ programming is fun!");
}
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
rdrake

|
Posted: Fri Aug 28, 2009 2:01 pm Post subject: RE:Write a simple source code |
|
|
Didn't the OP ask for C++ code? |
|
|
|
|
 |
Zren

|
Posted: Fri Aug 28, 2009 2:06 pm Post subject: Re: Write a simple source code |
|
|
Write a C++ source code that will give the correct output given above.
Mwahaha, never said it had to compile. I rename my empty source code file to "C++ programming is fun!.cpp".
None of your sass bout how the filename isn't actually the file itself either. >,< |
|
|
|
|
 |
saltpro15

|
Posted: Fri Aug 28, 2009 2:31 pm Post subject: Re: RE:Write a simple source code |
|
|
A.J @ Fri Aug 28, 2009 wrote: How about we open a new thread for an obfuscated code contest?
I'm on it. |
|
|
|
|
 |
bbi5291
|
Posted: Fri Aug 28, 2009 2:40 pm Post subject: Re: RE:Write a simple source code |
|
|
rdrake @ Fri Aug 28, 2009 2:01 pm wrote: Didn't the OP ask for C++ code?
It is C++. Try compiling it as C. |
|
|
|
|
 |
rdrake

|
Posted: Fri Aug 28, 2009 3:48 pm Post subject: Re: RE:Write a simple source code |
|
|
bbi5291 @ Fri Aug 28, 2009 2:40 pm wrote: rdrake @ Fri Aug 28, 2009 2:01 pm wrote: Didn't the OP ask for C++ code?
It is C++. Try compiling it as C. You're using C functions and a C header file pretending it's C++ code. Just saying.
Sure you can compile C as C++, but why not use the C++ equivalents when available? After all, C++ is more than just "C with classes." |
|
|
|
|
 |
md

|
Posted: Fri Aug 28, 2009 3:59 pm Post subject: RE:Write a simple source code |
|
|
Just because you need the C++ compiler, doesn't mean it's C++. If you use C libraries for things like basic IO you're not writing C++. |
|
|
|
|
 |
bbi5291
|
Posted: Fri Aug 28, 2009 5:06 pm Post subject: Re: Write a simple source code |
|
|
OP already received a satisfactory answer from posters before me. I was just having a bit of fun. As far as I am concerned, anything that compiles under a C++ compiler is C++. Even if you write it in machine code (this is actually possible, if you were wondering: char main[] = {...}; ). Obviously this goes against the spirit of writing a solution in C++, but oh well... |
|
|
|
|
 |
|