Showing posts with label return. Show all posts
Showing posts with label return. Show all posts

Tuesday, 8 September 2015

C++ Interview

Questions to apply for C++ position:

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 

Sunday, 7 September 2014

Linux File Commands

  • pwd- Output the current directory that you are in
  • ls - list the content of the current directory
  • ls -a - list all the content, including hidden files
  • ls -l - list the content and its information
  • cd someFolder – change directory to someFolder
  • cd .. - Go up a directory
  • cd - - Return to the previous directory
  • cp source destination – Copy sourceto destination
  • cp -r source destination – Copy a folder recursively from source to destination
  • mv source destination - Move (or rename) a file from source to destination
  • rm someFile- Remove someFile
  • rm -f someFile - Remove someFile without prompt
  • rm -r folder - Remove a folder and its content recursively
  • mkdir foldername – Create a new folder foldername
  • rmdir foldername – Remove an empty folder
  • file someFile – Show the file type of someFile
  • cat file1 file2 – Concatenate file1to file 2
  • cat > someFile – Concatenate standard input to someFile
  • less someFile - View and paginate someFile
  • head someFile - Show first 10 lines of someFile
  • tail someFile - Show last 10 lines of someFile
  • chmod unknown file - Change file permission of file to unknown
  • chown user:group file - Change ownership of fileto userand group group
  • ln -s source destination – Create a link from source to destination