C++ tutorial, C++ programs, C++ Exercises, C++ Example Programs

Saturday, February 2, 2013

Example Algorithms for C Plus Plus Programming

Today we will practice How to write some basic algorithms for simple C Plus Plus programs:


Algorithm 1: ADDITION
                                 This algorithm inputs two numbers then calculates and shows addition result of these two numbers. This algorithm uses three variables N1, N2, and ADDITION.

1. Start
2. Input N1, N2
3. Calculate ADDITION = N1 + N2
4. Display ADDITION
5. End

Algorithm 2: AGE CONVERSION
                                 This algorithm inputs age in years, converts it into dayas and shows result. This algorithm uses two variables YEARS and DAYS.

1. Start
2. Input YEARS
3. Calculate DAYS = YEARS x 365
4. Display DAYS
5. End


Algorithm 3: TEMPERATURE CONVERSION
                                 This algorithm inputs temperature  in Fahrenheit, converts it into Centigrade and shows result. This algorithm uses two variables F and C.

1. Start
2. Input F
3. Calculate C = 5/9 x (F-32)
4. Display C
5. End


Algorithm 4: PAY CALCULATOR
                                 This algorithm inputs name and basic pay of an employee, calculates and shows Net Pay. Where House Rent= 40% of basic pay, Medical Allowance 30%, Deduction = 5%.This algorithm uses 6 variables NAME, BASIC, NETPAY, HR, MA and DF.

1. Start
2. Input NAME, BASIC
3. Calculate HR = BASIC x 40/100
4. Calculate MA = BASIC x 30/100
5. Calculate D = BASIC x 5/100
6. Calculate NETPAY = BASIC + HR + MA - D
7. Display NAME, NETPAY
8. End

  Flowcharts of the above mentioned algorithms :
Share:

EasyCPPprogramming.blogspotcom

Labels