0% found this document useful (0 votes)
3 views11 pages

Machine Exercise Write Up 2

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)
3 views11 pages

Machine Exercise Write Up 2

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/ 11

University of Caloocan City

College of Engineering
Computer Engineering
Program

PROGRAMMING LOGIC AND


DESIGN SCHEDULE/ROOM

MACHINE EXERCISE NO. 1


COMMUNICATION THROUGH
CONSOLE

Submitted by:

NAME: STUDENT NO. SIGNATURE:


CAASI, CARL 20240177-E
ENVERZO, KYLE 20240181-E
LEAÑO APPLE 20240196-E

Submitted to:

Engr. Maria Concepcion A.


Mirabueno Professor
University of Caloocan City
College of Engineering
Computer Engineering
Program

October 3, 2024

I. Pseudocodes
1.
 Input side a and b.

 Calculate the value of c (Hypotenuse), square root of the side of a and


b

 Print the Hypotenuse


 End
2.
 Input the 2 numbers (num1) (num2)

 Calculate the difference, quotient, product, and sum of the 2


numbers

 Print the result

 End
3.

 Declare a value of fahrenheit and celsius


 Enter the fahrenheit temperature
 Calculate the fahrenheit to celsius (fahrenheit -32) * (5/9)
 Print the equivalent Celsius temperature
 End

II. Algorithms
1.
Step 1: start
Step 2: Input side a and b.
Step 3: Calculate the hypotenuse c using the formula c= √a² + b².

Step 4: print the value of


c. Step 5: End
University of Caloocan City
College of Engineering
Computer Engineering
Program
2.
Step 1: Start
Step 2: Input 1st num and 2nd
num Step 3: sum = 1st num +
2nd num
difference = 1st num - 2nd
num product = 1st num *
2nd num quiotient = 1st
num / 2nd num
Step 4: Print the sum, difference, product, and
quotient Step 5: End
3.
Step 1: start
Step 2: Declare the variables, fahrenheit and celsius
Step 3: Display a message reminding the user to enter the fahrenheit
temperature Step 4: Convert the value of fahrenheit to celsius (5/9) *
(fahrenheit -32)
Step 5: Print the celsius temperature
Step 6: End

III. Flowchart.
University of Caloocan City
College of Engineering
Computer Engineering
1. Program
University of Caloocan City
College of Engineering
Computer Engineering
2 Program
.
University of Caloocan City
College of Engineering
Computer Engineering
3 Program
.

IV. Source Codes.


1.
#include
<iostream>
#include
<cmath>
University of Caloocan City
College of Engineering
Computer Engineering
using namespace std; Program

int main()
{ double a,
b, c;
cout << "Enter the of length of Side
A: "; cin >> a;
cout << "Enter the length of Side
B: "; cin >> b;

c = sqrt((a * a) + (b * b));
cout << "The length of the hypotenuse is:"
<< c; return 0;
}
2.
Of #include <iostream>
#include <cmath>
using namespace std;

int main()
{
double num1, num2;

cout<<"Enter the first number: ";


cin>>num1 ;

cout<<"Enter the second number: ";


cin>>num2 ;

double sum = num1 + num2;


double difference = num1 - num2;
double product = num1 * num2;
double quotient = num1 / num2;

cout<<"Sum: " << sum << endl;


cout<<"Difference: " << difference << endl;
cout<<"Product: " << product << endl;
cout<<"Quotient: " << quotient << endl;

return 0;
}
University of Caloocan City
College of Engineering
Computer Engineering
" is " << difference << endl; Program

return 0;
}

3.

#include
<iostream> using
namespace std; int
main() {

float faren_heit, celc_ius;

cout << "Enter Farenheit


value: "; cin >> faren_heit;
cout << endl;

celc_ius = (faren_heit - 32) * 5 / 9;

cout << "For a farenheit temperature of "<< faren_heit << "


degrees." << endl; cout << " The equivalent Celcius temperature is
"<< celc_ius << "degrees.";

return 0;
}

V. Program Output
1.
University of Caloocan City
College of Engineering
Computer Engineering
Program
2.

3.
University of Caloocan City
College of Engineering
Computer Engineering
VI. Analysis Program

1. Hypotenuse Program:

The program uses the Pythagorean Theorem to calculate the

hypotenuse. The formula is implemented using the sqrt function

from the cmath library.

Inputs are taken from the user, and the program handles them
correctly to produce the output.

This program showcases basic mathematical computation and user input


handling in C++.

2. Arithmetic Operations Program:

The program takes two numbers and performs basic arithmetic


operations on them.

It demonstrates the use of C++ operators (+, -, *, /) and output


formatting.

Each result (sum, difference, etc.) is displayed immediately after the


calculation.

This program is useful in teaching how to manage multiple arithmetic


operations and interact with the user.

3. Temperature Conversion Program:

The program converts Fahrenheit to Celsius based on the well-known


formula .

It illustrates how to convert floating-point numbers in C++ and how


to display formatted output.

This program helps in understanding how to implement mathematical


formulas and convert between different units.
University of Caloocan City
College of Engineering
Computer Engineering
VII. Conclusion Program

1. Hypotenuse Program:

Conclusion: The program successfully calculates the hypotenuse of a


right triangle. It demonstrates the application of a well-known
mathematical theorem (Pythagoras) in programming.

2. Arithmetic Operations Program:

Conclusion: The program performs all basic arithmetic operations


(addition, subtraction, multiplication, division) accurately. It shows how
user inputs can be handled and processed in C++.

3. Temperature Conversion Program:

Conclusion: The program successfully converts Fahrenheit temperatures


to Celsius, demonstrating the ability to implement formulas in C+
+.Conclucion.

You might also like