[SOLVED] COMP1011 Laboratory 2- Basic Elements of C

25.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (2 votes)

This lab is designed to get you familiar with some basic elements of C programming. More specifically, you will learn some data types, operators, and a simple branching statement. After this lab, you are expected to be able to solve simple calculation problems and print plain patterns.
Problem: Print “O” or “E”
• Problem description
Write a program to print different patterns according to parity (odd or even). Given two integer numbers a and b. If (a*b) – (a/b) is odd, then print “O”. Otherwise, print “E”.
• Input & output requirements
The two input numbers are separated by a space. Outputs of the program are expected to follow the format as shown in sample results.
• Sample results
Sample 1
Please input two integers: 5 3↲
********
*
*
********
*
*
********
Sample 2
Please input two integers: 5 4↲
******
* *
* *
* *
* *
* *
******
• Tips:
a) 1, 3, 5 … are odd numbers; and 2, 4, 6… are even numbers. If ( n%2 == 1 ), then n is an odd number.
b) Any special cases, e.g., what if b = 0?

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.