60-140-01
Introduction to Algorithms and Programming I

Find links to simple examples for understanding concepts like call-by-value, call-by-reference, use of global variables in functions, and others. Note that several examples on these also are in the course book and in the online book example programs available on the front page of the course web site through book resources.

 

            Chapters 1-3 Examples on Algorithms/C programs and Six Problem Solving Steps

1.      Write an algorithm for finding sum of 2 given integer numbers.

2.      Write a C program for finding sum of 2 given integer numbers

3.      Show the six problem solving steps for finding the sum of 2 given integer numbers.

 

          Function Examples (Chapter 4)

1.      Find Sum of 2 given numbers using one function with only call-by-value parameters.

2.      Find Sum of 2 given numbers using one function with only call-by-reference parameters for function results but call-by-value parameters for function actual input values.

3.      Find Sum of 2 given numbers using one function with only global variables.

4.      Show 6 Problem Solving Steps for finding Sum of 2 given numbers using one function with call-by-value parameters.

           

            Nested if logic and switch_case Examples (Chapter 6)

Problem is: Given grades of 4 tests for a student, write a program that uses appropriate nested if instruction or switch_case instruction to print the grade earned by the student where grade is A if average is 90 or above, B if average is  80-89, C if average is 70-79,  D if averages 60-69 and F if average lower than 60.

1.      Positive if logic solution from top of condition_action table.

2.      Postive if logic solution from bottom of condition_action table.

3.      Negative if logic solution from top of condition_action table.

4.      Negative if logic solution from the bottom of condition_action table.

5.      The swich_case solution for the same problem above.


      Repetition Examples (Chapter 7)

1.                              Event Control Loop problem with while instruction: Find the sum of all numbers read up to a negative number.

2.                              Counter Control Loop problem with while instruction: Find the class average of 10 students’ quiz marks.

3.                              Using do_while instruction for problem 1 above: Find the sum of all numbers read up to a negative number.

4.                              do_while solution of problem 1 with first data element also checked:Find sum of numbers up to a negative one.

5.                              for loop solution for problem 2 above: Find the class average of 10 students’ quiz marks.

6.                              Backward counting for loop solution for problem 2: Find the class average of 10 students’ quiz marks.

 

Arrays Data Structure (Chapter 8)

1.      Find the average of 5 given marks with a one dimensional array.

2.      Find the average of 5 given marks with a one dimenstion array and a function.

3.      Find the average of  two assignment marks for 5 given students with 2D array and function.