1. What will this method return ?
const char* getWhenToDoSomething() { string aziTodo("today"); return aziTodo.c_str(); }
2. And this beautiful code, what will he print ?
char *ptr = new char[6]; strcpy(ptr, "12345"); int *x = (int*)ptr; x += 1; char* ptr2 = (char*)x; std::cout << *ptr2 << std::endl;
Tip: after casting from char to int, increment step will be bigger
Next be 3 dragons. They they will ask MATH.
While hard stuff,
use Google search when necessary.
3. Write a class for Complex numbers.
Also choose a solution for the fact that there can be two constructors :
Complex(double realNumber, double imaginaryNumber) Complex(double angle, double absoluteValue)
both taking 2 double arguments as parameters, what is the solution to take care of both constructors ?
4. Write the method to return the Taylor exponential function for x.
The same as the std::exp(double x) function. Provide the code to calculate the sum, the Taylor series sum( 1+ x + ...) and do not call std::exp(just maybe in assert to verify results).
5. Final level: Euler's formula.
Use both solutions from exercise 3. and 4. to calculate e to power i*x.
Assert that the result is equal to cos(x) + i*sin(x)
5 levels done,
next act will touch the map,
Bogdan Nicolae Visoiu
GL HF
No comments:
Post a Comment