Friday, August 3, 2012

Learning C++


Part -1 Sample programs for C++

Guidelines
·         In each case verify if the user has provided a meaning full input else provide message and request for a new input.
·         Always try to use functions for recursive tasks. Over time we can build a library with global functions.
·         Try to add comments where ever possible.


Programs
·         Conversion program
o   Convert to and from metric
§  Distance
§  Volume
§  Weight
o   Convert between upper and lower cases for a given sentence
§  Find each character and flip
§  Find only the first character of each word and change to upper case.
·         Sorting program
o   Request the user to enter number of elements. Then request user to enter the elements.
§  Bubble sort
§  Binary sort
·         Find (and replace)
o   Find a particular string in a paragraph and display how many times it repeats. Ask the user to enter a paragraph. Then request to user to enter a string to find.
§  Find the number of occurrences of the string stand alone
§  Find if the string is also a substring and report number of occurrences standalone, as a sub string and sun of both.
§  Ask the user if she/he would like to replace the string with another one. Read the new string if the answer is yes and perform the replacement.



Appendix
·         Conversion program
o   Distance
§  1Km = 0.621371miles
§  1m = 3.28084feet
o   Volume
§  1Liter = 0.264172gallons
o   weight
§  1Kg = 2.20462lb
·         Sorting program
o   4, 314, 221, 48, 2, 67, 86, 51, 256, 10.
·         Find (and replace)


  Download Visual C++ LINK -Microsoft visualstudio