This assignment consists of four short programs. Use Code::Blocks to complete your work. This assignment consists of four short programs. Use Code::Blocks to complete your work. You will submit the four C source code files for this assignment. Please zip the files and include your name in the name of the compressed file.
Part 1: Commenting Code
Include comments in source code that explain what the code does and how it does it. Commenting your code is best practice for clear communication and personal understanding. Begin by typing in the provided code, build and run it to ensure correctness, then add at least five comments explaining key parts of the code. Add a header comment with your name, course info, assignment part, and date, such as:
/* Ann Smith - IT2240 - U01a1 - Part 1 * 10/01/2015 Rev. 1 */
. Recompile and test after editing to confirm no syntax errors.
Part 2: About You
Create a program that prints three lines of text about yourself, including appropriate spacing and newline characters for readability. Include a header comment as shown above, formatted properly. Ensure the code is well-structured and adequately commented to explain its purpose and functionality.
Part 3: Integer and Floating Point Arithmetic
Write a single C program that performs and displays the results of four calculations: two involving integers and two involving floating-point numbers. Use hard-coded values for calculations. The program should print both the expressions and their results, with clear formatting and comments explaining the calculations. Include a header comment with your name and program identification.
Part 4: User Input
Develop a program that prompts the user to enter a character, an integer, and a floating-point number. After the user inputs these values, the program should display the entered values with proper formatting. Include comments explaining each step and a header with identifying information.
Paper For Above instruction
The following comprehensive C programming assignment emphasizes fundamental coding practices:
commenting, output formatting, arithmetic calculations, and user input handling. Each part reinforces core programming concepts and the importance of code readability, correctness, and user interaction.
Part 1: Commenting Code
This initial part underscores the significance of commenting within source code. Comments serve as documentation for both the programmer and others who may work with the code later. A well-commented program includes explanatory notes that clarify the purpose of code sections, logic flow, and specific operations. The instructions direct students to input a provided code snippet, compile and run it to understand its function, then add at least five meaningful comments. The inclusion of a header comment with personal and course details is required, fostering good documentation habits. After editing, recompilation ensures that no syntax errors are introduced, maintaining code integrity.
Part 2: About You
This program encourages students to personalize their coding experience by printing three lines about themselves. It's an exercise in string formatting, proper use of newline characters, and readability. Including a comment header communicates professionalism and clarity in code documentation. This task emphasizes attention to detail in output presentation, fostering better user interaction and ensuring that the terminal display is user-friendly.
Part 3: Integer and Floating Point Arithmetic
In this segment, students develop a consolidated program that demonstrates basic arithmetic operations involving integers and floating-point numbers. Using hard-coded values simplifies the learning process, allowing focus on correct expression syntax, proper ordering of operations, and output formatting. Printing both the calculation expressions and results reinforces understanding of how C handles different data types. Comments should explain the purpose of each calculation, ensuring the program is self-documenting and easy to follow.
Part 4: User Input
The final part centers on user interaction. Students build a program to prompt for a character, an integer, and a floating-point number. After reading the inputs using appropriate format specifiers, it displays each value back to the user. Proper input handling and output formatting are crucial here. Comments should detail each input step and the purpose of the print statements. This section helps develop confidence in
handling varied input types and in providing meaningful user feedback.
Overall, the assignment promotes good programming practices, including code documentation, logical structuring, and user-centered design. Completing these four programs not only solidifies foundational C skills but also instills disciplined habits vital for professional development in software engineering.
References
Kernighan, B. W., & Ritchie, D. M. (1988). The C Programming Language (2nd ed.). Prentice Hall.
Harbison, S. P., & Steele, G. L. (2002). C: A Reference Manual (4th ed.). Pearson Education.
ISO/IEC 9899:2018. Programming Languages — C. International Organization for Standardization.
Prata, S. (2012). C Primer Plus (6th ed.). Addison-Wesley.
Stephen G. Kochan. (2015). Programming in C (4th ed.). Addison-Wesley.
Deitel, P., & Deitel, H. (2015). C How to Program (8th ed.). Pearson.
Gries, D., & Schneider, F. B. (1993). A logical approach to programming. Springer.
Myers, G. J. (2011). Java in a nutshell. O'Reilly Media, Inc., which also provides insights on programming standards applicable across languages including C.
Stoet, G. (2010). GetData: Data Analysis & Visualization in C. Scientific Software Conference.
Online tutorials and official documentation from the GNU Project and Microsoft Docs for C programming best practices.