Act 8

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

NAME : SHERLY B.

ATILLO DATE : DECEMBER 16, 2022


YR. & SECTION : 1st YR. – IT1R12 INSTRUCTOR : MRS. G-ANNE LONOY

IT112 – COMPUTER PROGRAMMING 1


ACTIVITY 8
DO THE FOLLOWING ACTIVITIES.

1. Create a program with a function to find out whether the given number is either odd or even.

#include <iostream>

using namespace std;

int main ()

int age;

cout<<"Please enter your age: ";

cin>>age;

if (age%2 == 0) {

cout<<"even"<<endl;

}else{

cout<<"odd"<<endl;

return 0;

2. Create a program where you will ask 2 numbers from the user and get the product of those numbers. Use a function
to solve this problem.

#include <iostream>

using namespace std;

int main ()

int a=0, i=0;


int sum=0, product=0;

cout<<"Please give me two numbers: ";

cin>>a>>i;

sum=(a+i);

product=(a*i);

cout<<"\n\n";

cout<<"The sum of "<<a<<" and "<<i<<" is"<<sum<<" . ";

cout<<"The product of "<<a<<" and "<<i<<" is"<<product<<" . ";

return 0;

3. Write a program to print cumference and area of a circle of radius entered by the user by defining yout own
function.

#include <iostream>

using namespace std;

int main ()

float r, area;

cout<<"Enter the radius of the circle: "<<endl;

cin>>r;

area = 9*(r*r);

cout<<"the area of a circle is "<<area;

return 0;

You might also like