Sample C++ Programs

The Whole File:- Sample C++

  • average.C
  • mult.C (multiplication using addition)
  • fastmult.C (better algorithm for multiplication)
  • more.C (count number of characters and lines in a file)
  • merge.C (merge sort)
  • grade.C
  • grade2.C
  • gcd.C (Euclid’s algorithm)
  • fib.C (Fibonacci numbers)
  • fact.C (factorial)
  • exp.C (exponentiation using multiplication)
  • commute.C (weird behavior from C++ compiler)
  • cin.C (more weird C++)
  • temp.C (convert temperatures)
  • sqrt.C (compute square roots using Newton’s method)
  • sphere.C (compute distance between cities)
  • prime.C (check if a number is prime)
  • prime2.C (faster but probabilistic way)
  • prime3.C (avoid stupid C++ behavior in case of overflow)
  • pp.C (understanding call-by-value and call-by-reference)
  • pp2.C (evaluating expressions with side-effects)
  • ref.C (example of pass-by-reference)
  • oddeven.C (lots of functions)
  • void.C (converting value-returning functions to void functions)
  • side.C (bad style, side-effects, value-returning)
  • sc.C (understanding scope)
  • life.C (understanding life time and scope)
  • object.C (understanding the concept of objects)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s