Lex Project
Effective Software

C++ For Java Programmers

C++ is a powerful object oriented language, which is known for its performance, efficiency, and flexibility due to its ability to manipulate low-level memory. The C++ syntax is quite similar to Java syntax so Java programmers will find it easy to pick up the language.

Resources

There are many detail tutorials online about C++, here are the two popular ones: If you prefer book-like tutorials, here are the two recommendations: Here is the useful website to help you compile C++ file online.

Tips for leaning C++

  1. Always comment so it is easier to update your codes later.
  2. Learn the syntax carefully. Although C++ syntax is quite similar to Java syntax, there are certain differences.
  3. Differentiate between call by value and call by reference, since this concept is emphasized in C++.
  4. Data collection in C++ is also difference from in Java.
  5. Because C++ is not as good as Java in finding code errors, being careful in each small step is necessary.
  6. Keep practicing everyday by reading books and doing exercises.

Exercises

Here are some quick exercises for you to test your knowledge and skills
  1. Write a program to convert temperature from Celsius to Fahrenheit and vice versa.
    Toggle answer
  2. Write a program that will terminate if user type 5 otherwise keep running.
    Toggle answer
  3. Write a program to calculate area and circumference of circle for given radius.
    Toggle answer
  4. Write a program to print all permutation of the given string
    Toggle answer
  5. Write a program to make a guessing game with the following rules:
     Part 1: Computer generate a random number from 1 to 100. You guess until correct.
     Part 2: User think a number from 1 to 100. Train computer to guess correctly in less than 8 guesses.
    Toggle answer
  6. Write a program that asks user to enter the number of pancakes eaten by 10 different people.
      Part 1: Print the person eat the least and eat the most along with their number of pancakes.
      Part 2: Display list of people in order of number of pancakes eaten.
      Sample run:
         Person 4: ate 10 pancakes
         Person 3: ate 7 pancakes
         Person 8: ate 4 pancakes
         ........................
         Person 5: ate 0 pancakes
    Toggle answer