Programming Technique 1 / SECJ1013 - 02

Labs and Assignments

Over the span of 14 weeks, the Programming Technique subject provided extensive hands-on experience in software development through three lab sessions and two major assignments. These activities emphasized the practical application of programming concepts, problem-solving skills, and code implementation. Guided by our lecturer, we also learned to utilize advanced development tools and techniques, enhancing our ability to design, test, and debug programs. The labs and assignments challenged us to integrate theoretical knowledge with real-world programming scenarios, fostering a deeper understanding of the subject.

Introduction of Programming Technique 1

Programming Technique 1 introduces students to the fundamentals of programming and problem-solving using the C++ programming language. This course focuses on structured programming methodologies, emphasizing logical thinking, algorithm design, and the use of flowcharts or pseudocode to model solutions.

    Knowledge :

  • Arrays : Learn to store and manipulate collections of data efficiently.
  • Pointers : Understand memory management and how to access data directly in memory.
  • Looping Structures : Use loops (for, while, do-while) to handle repetitive tasks and iterate over data.
  • Library Functions : Leverage prebuilt C++ functions for tasks like mathematical computations, string manipulations, and file handling.
  • User Defined Functions :Develop modular and reusable code by creating custom functions to perform specific tasks.
  • Reflection : What is your reflection for this subject ?

    The Programming Technique course was a great learning experience that built my confidence in coding with C++. I learned how to use arrays, pointers, loops, and control structures to solve problems logically and efficiently. Writing user-defined functions taught me the importance of reusable and modular code, while library functions showed how to simplify tasks using prebuilt tools.

rounded-circle

Lab 1 : Programming Problem Solving

Lab Exercise 1 focuses on programming problem-solving by emphasizing the practical application of pseudocode and decision tables. This exercise required analyzing and completing a trace table for given pseudocode and writing new pseudocode to implement decision-making logic based on input parameters. The tasks involved detailed logical reasoning and provided a platform to strengthen fundamental programming skills.

    Skills Successfully Acquired in This Lab:

  • Understanding Pseudocode: Translating pseudocode into logical steps and completing trace tables to track variable changes and program flow.
  • Error Detection: Identifying logical errors or inefficiencies in pseudocode and resolving them.
  • Systematic Thinking: Breaking down complex problems into smaller, manageable steps.
  • Algorithm Design: Creating structured, efficient, and understandable algorithms.

Reflection for Lab 1 : What actually the biggest impact that you get by completing this Lab 1 ?

Completing Lab 1 had a big impact by strengthening problem-solving and critical thinking skills. It helped develop logical thinking through tracing program flows and designing algorithms. Writing pseudocode for decision tables improved decision-making and attention to detail, ensuring accurate and efficient solutions. This lab also bridged theory with practical application, boosting confidence in handling programming challenges. Overall, it built a solid foundation for tackling problems methodically and effectively.

Lab 2 Answer

Lab 2 Answer Sheet : Click here
Coding Answer : Click here !!

Lab 2 : Elementary Programming and Control Strutures

Lab Exercise 2 focuses on building foundational programming skills in C++. Students will design a flowchart and write a program for a basic calculator that performs addition, subtraction, multiplication, and division. The program prompts users to input an operator and two numbers, performs the operation using a switch-case structure, and displays the result. It also handles invalid inputs with an error message and repeats the process using a do-while loop until the user decides to stop. This exercise combines algorithm design and coding to strengthen problem-solving and programming logic.

    Skills Successfully Acquired in This Lab :

  • Control Structures: Utilizing switch-case to handle multiple operation choices based on user input.
  • Error Handling: Managing invalid operator entries with a default case in the switch statement.
  • Logical Flow: Structuring the program to handle input, process it, and provide output seamlessly.
  • User-Friendly Interface: Designing prompts and outputs that make the program intuitive for the user.

Reflection for Lab 2 : What actually the biggest impact that you get by completing this Lab 2 ?

Completing Lab Exercise 2 helps build essential programming skills and confidence. It teaches how to break down problems, use loops and conditions effectively, and handle errors to make programs user-friendly. Testing and debugging improve attention to detail, while applying basic concepts like arithmetic and control flow shows how simple tools can solve real problems, inspiring confidence to tackle bigger challenges.

Lab 3 Material

Lab 3 Answer Sheet : Click here !!
Coding Sample for Lab 3 : Click here !!

Lab 3 : Functions

Lab Exercise 3 focuses on understanding and using functions in C++ programming. Students will explore predefined and programmer-defined functions, learn about variables and constants (local, global, and static), and practice working with function libraries for common tasks like calculations and string operations. The lab also includes debugging exercises and a task to calculate a rectangle’s area using user-defined functions. This exercise strengthens skills in modular programming, making code more efficient, clear, and reusable.

    Skills Successfully Acquired in This Lab 3 :

  • Defining Functions : Understand how to declare and define functions in C++ with the appropriate syntax (return type, function name, parameters).
  • Function Parameters and Arguments : Learn how to pass data into functions using different methods: pass-by-value and pass-by-reference.
  • Error Handling : Gain an understanding of how to handle errors, such as invalid input or exceptions, within functions.
  • Recrusion : Understand the concept of local and global variables and how they interact within functions.

Reflection for Lab 3 : What actually the biggest impact that you get by completing this Lab 3 ?

Lab 3 on Functions, problems were broken down into smaller, manageable parts using functions in C++. Functions were defined, data was passed through parameters, and results were returned using the return statement. The difference between pass-by-value and pass-by-reference was explored, helping to optimize the code. Function overloading was introduced, allowing the same function name to be used with different parameters.

Assignment Material

Answer Sheet : Click here !!
Coding Sample : Click here !!

Assignment 1 : Topic 1 - Topic 3

This C++ program calculates the monthly salary for different types of employees—general, contract, and toy workers—based on factors like overtime, work hours, or toy production. It ensures valid input and adjusts salary accordingly, offering a flexible solution for various pay structures.

Skills Successfully Acquired in This Lab 3 :

  • Function Design: Creating modular functions (getCode(), getCategory(), etc.) to improve readability and reusability.
  • Mathematical Computation: Calculating salaries based on various conditions, including overtime and production output.
  • User Interaction: Using cin and getline for interactive user input.
  • Dynamic Decision-Making: Adjusting salary calculations based on employee type, category, and other factors.

Reflection for Assignment 1 : What actually the biggest impact that you get by completing this Assignment ?

By completing this coding exercise, a deeper understanding of decision-making, functions, and modular programming in C++ was gained. Complex tasks were simplified by breaking them into smaller, reusable functions like getCode() and getSalaryB(). Input validation was improved, ensuring user errors were handled gracefully. Real-world scenarios, such as salary calculations, were explored, showing how programming can solve practical problems. Confidence was boosted, and readiness to handle future coding challenges was strengthened.

Assignment 2 Materials

Assignment 2 Answer Sheet : Click here !!
Coding Sample for Question 1 : Click here !!
Coding Sample for Question 2 : Click here !!
Input text for Question 2 : Click here !!

Assignment 2 : Input, Output and Array

The provided C++ code examples highlight essential programming skills in a practical and easy-to-understand way. The first code focuses on merging two arrays, calculating the average, range, and odd numbers, showcasing basic array operations and arithmetic. The second code reads item data from a file, calculates discounted prices, and displays a neatly formatted table. It demonstrates file handling, modular functions, and professional output formatting. Together, these examples cover key concepts like arrays, file I/O, data processing, and clean output presentation, offering a great starting point for learning structured programming in C++.

Skills Successfully Acquired in This Assignment 2 :

    Array Manipulation
  • Merging two arrays into a single dataset.
  • Performing calculations on arrays (average, range, odd number count).
  • File Input / Output
  • Reading structured data from a file.
  • Handling file errors gracefully.
  • Data Formatting
  • Displaying data in a clean, tabular format with aligned columns using setw and setprecision.
  • Modular Design:
  • Writing reusable functions (Input, Output) to separate concerns, improving code clarity and maintainability.

  • Reflection for Assignment 2 : What actually the biggest impact that you get by completing this Assignment ?

    Completing these two coding exercises helps you master key skills like reading data from files, processing arrays, and performing calculations such as averages and discounts. You’ll learn how to format output neatly into tables and handle errors when reading from files. These skills are directly applicable to real-world tasks, like managing product inventories or generating sales reports. Overall, you’ll become more confident in working with data, preparing you for more complex programming challenges in fields like software development and data analysis.