Last active
May 3, 2017 08:23
-
-
Save jgreitemann/9baa7e3034af599350ea45746992cfac to your computer and use it in GitHub Desktop.
Exercise 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
int square(int x) { | |
return x*x; | |
} | |
int main() { | |
int a = 5; | |
int b = 2; | |
int c = a + b; | |
int d = square(c); | |
if (d > 2) { | |
c++; | |
} | |
printf("%d\n", c); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// your macro goes here | |
int main() { | |
std::cout << "#1: " << SQUARE(4) << std::endl; | |
std::cout << "#2: " << SQUARE(2*2) << std::endl; | |
std::cout << "#3: " << SQUARE(2+2) << std::endl; | |
double one_sixteenth = 1. / SQUARE(4); | |
std::cout << "#4: " << 1. / one_sixteenth << std::endl; | |
int a = 3; | |
std::cout << "#5: " << SQUARE(++a) << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment