int k; bool IsEven(int n); k-; if (k==1) { k += 1; }
b) State two advantages of using functions in program design.
bool IsPrime(int n) // Returns true if n>1 and the only divisors of n are 1 and n // Returns false otherwise (function body not shown)fill in the main() function below so that it prints all prime numbers between 1 and 10,000 to the console output cout. A prime number is an integer p for which the function invocation IsPrime(n) returns true. Consecutive numbers should be separated by spaces in the output.
a) int i=12; cout << i%5; b) int j=9; cout << ++j; c) int k=1; while (k/4 < 2) k*=3; cout << k; d) bool flag=false; for (int i=1; i<=1000; i++) if (i%3 == 0) flag = !flag; if (flag) cout << "true"; else if (!flag) cout << "false"; e) int lambda = 32; while (lambda > 0) { int k=lambda; while (k > 0) { cout << "*"; k /= 2; } cout << endl; lambda /= 3; }
int main() { double x x = 3; y = 4.5; cout << the value of x+y equals << x+y; return 0.0; }
bool UFO(int n) { while (n%2 == 0) n/=2; return (n==1); }