0% found this document useful (0 votes)
34 views

Lab2 Writing Simple Programs

This document outlines a laboratory activity on writing simple programs. It provides 10 programming problems to solve, covering topics like calculating the mean, arithmetic operations, BMI, distance formula, and interest calculation. It instructs students to write C code solutions in an IDE, provide sample test data inputs and outputs, and submit a laboratory report with their coded solutions and output screenshots. The report should include the student name, program, IDE used, problem descriptions, C code snippets, and a sample test program output for each problem. Points will be awarded based on correctly implementing inputs, outputs, and arithmetic operations for each problem.
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)
34 views

Lab2 Writing Simple Programs

This document outlines a laboratory activity on writing simple programs. It provides 10 programming problems to solve, covering topics like calculating the mean, arithmetic operations, BMI, distance formula, and interest calculation. It instructs students to write C code solutions in an IDE, provide sample test data inputs and outputs, and submit a laboratory report with their coded solutions and output screenshots. The report should include the student name, program, IDE used, problem descriptions, C code snippets, and a sample test program output for each problem. Points will be awarded based on correctly implementing inputs, outputs, and arithmetic operations for each problem.
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/ 5

USJR, SCHOOL OF ENGINEERING

DEPARTMENT OF COMPUTER
ENGINEERING CEBU CITY, PHILIPPINES

LABORATORY ACTIVITY
2
WRITING SIMPLE
PROGRAMS

A. Objectives
a. To be able to write simple programs using the introduced programming language
and development tool
b. To be able to write program code solutions to simple mathematical problems
c. To be able to use program syntax on simple input/output of different data types
d. To be able to use constants and variables in the program
e. To be able to construct expressions and statements on the given problems
f. To be able to use and apply principles of arithmetic expressions and user-input
function.

B. Activity Instructions
Write your program on the code editor of the Integrated Development Environment
(IDE) software (DevC or other IDE or any code editor) you are using.
a. Run your Integrated Development Environment (IDE) offline or online.
Create new file under File Tab located at the left-most side of the IDE interface
Save your file and rename it LASTNAME_Problem#.c
b. Create a folder for all your laboratory activities in your computer. You should
separate program file for each activity problem under one folder. The folder name
should be your LASTNAME_ES9_LA2
c. Solve the programming problems found in Section D. There are sample input and
output for the problem (applicable) which you can reference.
d. Compile, run and debug your codes to check the correctness of the output of your
program.
e. If you are done writing your solution codes, submit LABORATORY REPORT in the
LMS on or before September 05, 2023 05:00PM.

C. Submission Instructions
Submit your work in the Adelante LMS – ES9 on the section Laboratory Activities
Submission for Laboratory Activity 2. Upload your laboratory report in pdf format with file
name LASTNAME_ES9_LA2.pdf. See the format for the laboratory report on the next
section E.

FUNDAMENTALS IN PROGRAMMING | LABORATORY MANUAL SY 2020-


USJR, SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER
ENGINEERING CEBU CITY, PHILIPPINES
D. PROBLEMS

Problem No. 1 Write a program that asks for five integers and displays the mean.
Input/s n1, n2, n3, n4, and n5 are the five integers
Output/s mean is the mean of the five integers
Sample Test Data
Test No. INPUT OUTPUT
1 12345 3
2 6 7 8 9 10 8
3 11 12 13 14 15 15
4 10 20 30 40 50 30
5 22 45 67 88 90 62

Problem No. 2 Write a program that asks for two integers and performs addition,
subtraction, multiplication and division operations.
Input/s n1 and n2 are the two integers
Output/s sum, diff, prod, and quotient are the output of the operations
Sample Test Data
Test No. INPUT OUTPUT
1 55 3 58 52 165 18
2 -15 5 10 - 20 -75 -3
3 66 0 66 66 0 # (error)
4 0 -23 -23 23 0 0
5 100 1999 2099 -1899 199,900 0

Problem No. 3 Write a program to calculate the body mass index (BMI)
Input/s Using height and weight as inputs (assume the cm and kg SI unit)
Output/s bmi is the calculated BMI
Sample Test Data
Test No. INPUT OUTPUT
1 150 55 24.4
2 180 65 20.1
3 155 49 20.4
4 170 90 31.1
5 160 45 17.6

FUNDAMENTALS IN PROGRAMMING | LABORATORY MANUAL SY 2020-


USJR, SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER
ENGINEERING CEBU CITY, PHILIPPINES
Problem No. 4 Write a program to find the discriminant using the quadratic formula
Input/s a, b, and c are given
Output/s D is the discriminant
Sample Test Data
Test No. INPUT OUTPUT
1 3 4 -2 40
2 3 4 -5 76
3 2 5 -3 49
4 2 -2 -6 52
5 4 5 -6 121

Problem No. 5 Write a program to convert weight from kilogram to pound


Input/s kgs is the weight in kilogram
Output/s lbs is the equivalent weight in pound
Sample Test Data
Test No. INPUT OUTPUT
1 100 220.462
2 50 110.231
3 33 72.7525
4 20 44.0925
5 20.5 45.19476

Problem No. 6 Write a program to solve for the distance formula given two points
Input/s PX1, PY1 are the coordinate of point 1, PX2, PY2 are the coordinate of
point 2
Output/s PD is the distance of two points
Sample Test Data
Test No. INPUT OUTPUT
1 (2,2) (3,-5) 7.07
2 (-3,0.2) (0,-3) 4.3863
3 (9,1) (2,10) 11.4017
4 (6,0) (10,-5) 6.4031
5 (1,6) (9,-5) 13.6014

FUNDAMENTALS IN PROGRAMMING | LABORATORY MANUAL SY 2020-


USJR, SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER
ENGINEERING CEBU CITY, PHILIPPINES

Problem No. 7 Write the formula that solves the problem: A car takes 4 hours to
cover a certain distance when it travels at speed of 40 mph. What is
the speed of the car to cover the same distance in one hour and 30
minutes.
Input/s speed1 is the speed of the car, distance is the distance traveled by the
car, and traveltime is the time traveled by the car
Output/s speed2 is the speed of the car traveling in the same distance in one
hour and 30 minutes.
Expected formula written in C :

Problem No. 8 Write the formula to calculate the total resistance of a series
connected resistors.
Input/s R1, R2, R3 and R4 are the connected resistors
Output/s Total_R is the total resistance of the serially connected resistors
Expected formula written in C :

Problem No. 9 Write a program that solves the surface area of a rectangular prism by
asking the parameters by user-input.
Input/s PARAM1, PARAM2, PARAM3 are the known parameters to get the
surface area
Output/s AREA is the surface area of the rectangular prism
Expected formula written in C :

Problem No. Write a program that solves the monthly interest earned given the
10 principal amount and the annual interest.
Input/s P is the principal amount borrowed and Q is the annual interest rate
Output/s MON_INTEREST is the monthly interest

FUNDAMENTALS IN PROGRAMMING | LABORATORY MANUAL SY 2020-


USJR, SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER
ENGINEERING CEBU CITY, PHILIPPINES

E. LABORATORY ACTIVITY REPORT FORMAT

NAME

DEGREE PROGRAM &YEAR LEVEL


IDE/CODE EDITOR USED

Laboratory Activity #
Title
A. PROGRAMMING SOLUTION/S

Problem Problem Description


No. #
C Code Line/s Solution
Input/s
Output/s
Complete C Code
Provide a screenshot or Copy the code from the editor

Sample Test Program Output


Provide a screenshot of the run program

F. Grading
Each Problem is a total of 10 points. ( 3 points for correct input
implementation, 3 points for correct output implementation and 4 points
for correct arithmetic operation implementation). Total possible highest
score is 100 points.

FUNDAMENTALS IN PROGRAMMING | LABORATORY MANUAL SY 2020-

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy