Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views3 pages

Cosc 202 Assignment

The document contains two C++ programs. The first program performs addition, multiplication, and average calculation of user-input numbers, while the second program detects if a number is even or odd and calculates the summation from 1 to that number. Both programs demonstrate basic input/output operations and function usage in C++.

Uploaded by

dhavesilver
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Cosc 202 Assignment

The document contains two C++ programs. The first program performs addition, multiplication, and average calculation of user-input numbers, while the second program detects if a number is even or odd and calculates the summation from 1 to that number. Both programs demonstrate basic input/output operations and function usage in C++.

Uploaded by

dhavesilver
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Udechukwu David Chibuikem

23/0161

Software Engineering Group E

Number 1

#include <iostream>

using namespace std;

int addTwoNumbers(int a, int b) {

return a + b;

int multiplyThreeNumbers(int x, int y, int z) {

return x * y * z;

double calculateAverage() {

double num1, num2, num3;

cout << "Enter three numbers: ";

cin >> num1 >> num2 >> num3;

return (num1 + num2 + num3) / 3.0;

int main() {

int a, b, x, y, z;

cout << "Enter two numbers to add: ";

cin >> a >> b;

cout << "Sum: " << addTwoNumbers(a, b) << endl;

cout << "Enter three numbers to multiply: ";

cin >> x >> y >> z;

cout << "Product: " << multiplyThreeNumbers(x, y, z) << endl;

cout << "Average: " << calculateAverage() << endl;


return 0;

Number 2

#include <iostream>

Using namespace std;

Bool detectEven(int n) {

Return (n % 2 == 0);

Bool detectOdd(int n) {

Return (n % 2 != 0);

Int summation(int n) {

Int sum = 0;

For (int i = 1; i <= n; i++) {

Sum += i;

Return sum;

Int main() {

Int n;

Cout << “Enter a number: “;

Cin >> n;

If (detectEven(n)) {

Cout << n << “ is an even number.” << endl;

} else {

Cout << n << “ is an odd number.” << endl;

}
Cout << “Summation from 1 to “ << n << “ is: “ << summation(n) <<
endl;

Return 0;

Int main() {

return yourmain();

You might also like