-
C > C++ (humorous)
Code:
#include <limits.h>
#include <stdio.h>
#include <iostream.h>
int main()
{
int C = INT_MAX;
int C_plus_plus = C + 1; // C_plus_plus is equivilent to C++
if (C > C_plus_plus) {
printf("C is greater!\n");
} else {
cout<<"C++ is greater!"<<endl;
}
return 0;
}
-
-
Yeah, C rules.
I prefer printf to cout.
-
You have an error in your code.
Code:
#include <limits.h>
#include <stdio.h>
#include <iostream.h>
int main()
{
int C = (INT_MAX-1);//much better
int C_plus_plus = C + 1; // C_plus_plus is equivilent to C++
if (C > C_plus_plus) {
printf("C is greater!\n");
} else {
cout<<"C++ is greater!"<<endl;
}
return 0;
}
-
Change it to this:
Quote:
Originally posted by LrdChaos
Code:
#include <limits.h>
#include <stdio.h>
#include <iostream.h>
int main()
{
int C = INT_MAX;
int C_plus_plus = C++; // C_plus_plus is equivilent to C++
if (C > C_plus_plus) {
printf("C is greater!\n");
} else {
cout<<"C++ is greater!"<<endl;
}
return 0;
}
-
>You have an error in your code.
Not an error, it's supposed to be that way I think. The most common result of overflowing a signed integer is to wrap around back to the highest negative number. Thus making C better than C++.
Nice abuse of overflowing a signed integer, but the result won't be the same with everyone since the result of a signed integer overflow is undefined. :)
-Prelude
-
Hmmm...
-
Prelude, it was a joke. If he subtracted one away from INT_MAX, it would make C++ better than C.
-
I think magos is the most creative. . .
int c_plus_plus = c++; :D
ooh that just made me laugh.:)