C++ Programming GalleryThe Programming Challenge
Challenge 1 – Why don’t we get: Successfully? in C++

Difficulty ![]() |
![]() |
This Challenge was proposed for the now defunct C/C++ programming list CWORLD in 1999.
The source code of the challenge has been updated to modern C++, but maintaining the essence of the challenge, which its original author wanted to transmit.
Date: 06-VIII-2000
Created by: Francisco Manuel Martín Delfa
Challenge winner: José Ramírez Flores
FMMD 3-VIII-2000
The challenge 0001
Why don’t we get:
The operation was performed:
Successfully.
Is it very easy?
Source Code
#include <iostream>
#define ADD(x,y) ((x) + (y))
#define SUB(x,y) ((x) - (y))
#define MUL(x,y) ((x) * (y))
#define DIV(x,y) ((x) / (y))
int main(void)
{
int x, y, z;
x = 5;
y = 2;
z = ADD(DIV(x, y), MUL(x, y)) * 2;
std::cout << "\nThe operation was performed:\n";
if (z=!0) {
std::cout << "\n\tIncorrectly.\n";
}
else {
std::cout << "\n\tSuccessfully.\n";
}
return 0;
}
AND FINALLY I CAN ONLY SAY …. BEST OF LUCK AND MAY THE BEST CODE WIN….
If you liked this challenge remember to leave a comment in our guestbook