Skip to content

Instantly share code, notes, and snippets.

@jgreitemann
Last active May 3, 2017 08:23
Show Gist options
  • Save jgreitemann/9baa7e3034af599350ea45746992cfac to your computer and use it in GitHub Desktop.
Save jgreitemann/9baa7e3034af599350ea45746992cfac to your computer and use it in GitHub Desktop.
Exercise 2
#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);
}
#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