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 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
A.J
![](http://compsci.ca/v3/uploads/user_avatars/119833057151651227b0d87.gif)
|
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;
}
|
|
|
|
|
|
![](images/spacer.gif) |
jhooper3581
|
Posted: Fri Aug 28, 2009 8:50 am Post subject: (No subject) |
|
|
Thanks for the reply! |
|
|
|
|
![](images/spacer.gif) |
saltpro15
![](http://compsci.ca/v3/uploads/user_avatars/9776171634ced6278d14c2.png)
|
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;
}
|
|
|
|
|
|
![](images/spacer.gif) |
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;
}
|
|
|
|
|
|
![](images/spacer.gif) |
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. |
|
|
|
|
![](images/spacer.gif) |
A.J
![](http://compsci.ca/v3/uploads/user_avatars/119833057151651227b0d87.gif)
|
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? |
|
|
|
|
![](images/spacer.gif) |
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!");
}
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
rdrake
![](http://compsci.ca/v3/uploads/user_avatars/113417932472fc6c9cd916.png)
|
Posted: Fri Aug 28, 2009 2:01 pm Post subject: RE:Write a simple source code |
|
|
Didn't the OP ask for C++ code? |
|
|
|
|
![](images/spacer.gif) |
Zren
![](http://compsci.ca/v3/uploads/user_avatars/1110053965512db6185954b.png)
|
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. >,< |
|
|
|
|
![](images/spacer.gif) |
saltpro15
![](http://compsci.ca/v3/uploads/user_avatars/9776171634ced6278d14c2.png)
|
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. |
|
|
|
|
![](images/spacer.gif) |
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. |
|
|
|
|
![](images/spacer.gif) |
rdrake
![](http://compsci.ca/v3/uploads/user_avatars/113417932472fc6c9cd916.png)
|
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." |
|
|
|
|
![](images/spacer.gif) |
md
![](http://compsci.ca/v3/uploads/user_avatars/1849317514ed6c4399768d.png)
|
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++. |
|
|
|
|
![](images/spacer.gif) |
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... |
|
|
|
|
![](images/spacer.gif) |
|