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

(M1-TECHNICAL) Done

Uploaded by

K Z
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)
55 views

(M1-TECHNICAL) Done

Uploaded by

K Z
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/ 16

COLLEGE OF COMPUTER STUDIES AND MULTIMEDIA ARTS

CCS0006L
(COMPUTER PROGRAMMING 1)

EXERCISE

1
FAMILIARIZATION OF C++ ENVIRONMENT

Student Name / Group


Name: Klaus Zurik B. Navor
Name Role
Members (if Group):

TN07
Section:
Sir. Hadji Tejuco
Professor:
I. PROGRAM OUTCOME/S (PO) ADDRESSED BY THE LABORATORY EXERCISE
 Apply knowledge through the use of current techniques and tools necessary for the IT profession. [PO: I]

II. COURSE LEARNING OUTCOME/S (CLO) ADDRESSED BY THE LABORATORY EXERCISE


 Solve computing problems using design tools that meets specific requirements. [CLO: 1]

III. INTENDED LEARNING OUTCOME/S (ILO) OF THE LABORATORY EXERCISE


At the end of this exercise, students must be able to:
 Familiarize an environment in creating a C++ program
 Create a simple program, compile and run it.

IV. BACKGROUND INFORMATION

Microsoft Visual C++, usually shortened to Visual C++ or MSVC, is the name for the C++, C, and assembly
language development tools and libraries available as part of Visual Studio on Windows. Visual C++ can be used to
write anything from simple console apps to the most sophisticated and complex apps for Windows desktop, from
device drivers and operating system components to cross-platform games for mobile devices, and from the smallest
IoT devices to multi-server high performance computing in the Azure cloud.

CCS0003L-Computer Programming 1 Page 2 of 16


A. Create a C++ project in Visual Studio 2019
1. From the main menu, choose File > New > Project to open the Create a New Project dialog box.
2. At the top right of the dialog box, set Language to C++ in "All languages", set Platform to Windows
in "All platforms", and set Project type to Console in "All project types".
3. From the list of options for project types, choose Console App then click Next.
4. In the next page, enter a name for the project, and specify the project location if desired.
5. Click the Create button to create the project.

B. Build a Project
Once you have entered all of your source code, you are ready to build.
 On the menu bar, choose Build > Build Solution from the Build menu or just press Ctrl+Shift+B.

C. Run a Code
You can now run your program.
 On the menu bar, choose Debug > Start without debugging or just press Ctrl + F5.

V. LABORATORY ACTIVITY

ACTIVITY 1.1: Fun Run

PROCEDURE:
1. Create two projects namely fun1 and fun2.
2. Encode the following C++ programs in fun1.cpp and fun2.cpp respectively.
3. Build and run the program.
4. Illustrate the output of the program.

CCS0003L-Computer Programming 1 Page 3 of 16


fun1.cpp

Output of the Modified Program:

1.Run and compile the program. Enter 1981 as the input. Paste the screen output below.

CCS0003L-Computer Programming 1 Page 4 of 16


2.Run and compile the program. Enter 2020 as the input. Paste the screen output below.

fun2.cpp

CCS0003L-Computer Programming 1 Page 5 of 16


Output of the Modified Program:

1.Run and compile the program. Enter 1231 as the input. Paste the screen output below.

2.Run and compile the program. Enter 23432 as the input. Paste the screen output below.

CCS0003L-Computer Programming 1 Page 6 of 16


ACTIVITY 1.2: Correct Me If I Am Wrong

PROCEDURE:

1. Created a project named try then encode the C++ program below in try.cpp

2. Save the C++ program.


3. Build and run the program.
4. The compiler points to what line number?
Answer: It points to Line number 1
5. Put # symbol before the “include” word. Compile and run again the program. What happened?
It points to what line number?
Answer: It detects an error and it points to Line number 6
6. Put ; symbol after the statement “int n1,n2,s”. Compile and run again the program. What
happened? It points to what line number?
Answer: It detects an error and points to Line number 7
7. Change the << to >> in the statement “cin<<n1;”. Compile and run again the program. What
happened? Does it successfully execute the program?
Answer: Yes, it executes the program
8. Type 10 as the first number and 5 as a second number. What is the screen output?
Screen Output: (Paste the screen output below.)

9. The program should add the two numbers. Is the result correct?
Answer: no, it is not correct

CCS0003L-Computer Programming 1 Page 7 of 16


10.Change the – to + in the statement “s=n1– n2;” Compile and run again the program. What
happened? Does it successfully execute the program?
Answer: Yes, it executes the program
11.Type 10 as the first number and 5 as a second number. What is the screen output?
Screen Output:

12.Is the output 15?


Answer: Yes, it is 15
13.Copy and paste in the Program section below the modified program.
Program:

Sample Output:

CCS0003L-Computer Programming 1 Page 8 of 16


ACTIVITY 1.3: Arrange Me

Directions: Arrange the block of codes to form the C++ program that will satisfy the given
problem specification. Encode your answer in Visual Studio C++ then build and run. Paste your C++
program in Visual C++ Program column and the sample output in the Output column.

Problem 1. Create a project named digits then create a program that asks a user a 3-digit number and
displays the hundreds, tens and ones digits of the inputted number.
Block of Codes Block of Codes
(in correct order)
A. C.
#include<iostream>
using namespace std;
B. F.
int main()
{
C.
int number, hundreds, tens, ones;
cout << "Enter a 3-digit number: ";
D. cin >> number;
E.
hundreds = number / 100;
number = number % 100;
E.
B.
tens = number / 10;
F. ones = number % 10;
D.
cout << "Hundreds digit: " << hundreds<<endl;
cout << "Tens digit: " << tens << endl;
cout << "Ones digit: " << ones << endl;
A.
return 0;
}

Visual C++ Program Output

CCS0003L-Computer Programming 1 Page 9 of 16


Problem 2. Create a project named swap then create a program that swaps the two numbers entered
by the user.
Block of Codes Block of Codes
(in correct order)

CCS0003L-Computer Programming 1 Page 10 of 16


A. F.
#include<iostream>
using namespace std;
D.
B. int main()
{
int a, b, c;
B.
cout << "Enter value of a: ";
C.
cin >> a;
cout << "Enter value of b: ";
D.
cin >> b;
C.
c = a;
E. G.
a = b;
F. E.
b = c;
A.
G. cout << "After swaping
a : " << a <<" b: " <<
b;
return 0;

CCS0003L-Computer Programming 1 Page 11 of 16


Visual C++ Program Output

Problem 3. Create a project named leap then create a program that identifies whether the inputted year
is a leap year or not.
Block of Codes Block of Codes
(in correct order)
A. C.
#include <iostream>
using namespace std;
D.
int main()
B. {
int year;
cout << "Enter a year: ";
cin >> year;
C. A.
if ((year % 4) == 0)
{
cout << "Leap Year";
}
D. E.
else
{
cout << "Not a Leap Year" << endl;
}
B.
return 0;
E.
}

CCS0003L-Computer Programming 1 Page 12 of 16


Visual C++ Program Output

CCS0003L-Computer Programming 1 Page 13 of 16


VI. QUESTION AND ANSWER

Directions: Briefly answer the questions below.

 What is IDE?
An Integrated Development Environment (IDE) is a software application that provides
comprehensive facilities for software development. It combines tools like a code editor,
compiler, debugger, and an integrated terminal. By integrating features such as code editing,
building, testing, and packaging into a single, easy-to-use tool, IDEs significantly boost
developer productivity. They are commonly used by programmers and software developers to
streamline their programming workflow and make the development process smoother.

 In running a program, what shortcut key should be pressed?

The F10 key

 In compiling and running a program, what shortcut key should be pressed?

The F11 key

 Discuss briefly syntax error and logical error.

Syntax error - a mistake in code that violates the programming language's rules and prevents it from
executing correctly.
Logical error - a bug in a program that causes it to operate incorrectly, but not to terminate abnormally.

 In Activity 1.2, which line statement(s) consists of syntax error? How are you going to correct this
type of error?

Line 1, put the hashtag (#) before the “include” word.


Line 5, put the semicolon after the statement “int n1,n2,s”.
Line 7, by changing << to >> in the statement “cin << n1;”.
Overall we correct them by putting in the missing symbols and changing incorrect symbols.
 In Activity 1.2, which line statement(s) consists of logical error? How are you going to correct this
type of error?

Line 10, by changing the “-” to “+”.


Overall we correct them by changing the order of operations to make sense.

CCS0003L-Computer Programming 1 Page 14 of 16


VII. REFERENCES
 Abraham (2015). Coding for dummies. John Wiley and Sons: Hoboken, NJ
 Zak, D (2015). An Introduction to Programming with C++. 8th Edition
 Cadenhead, R et. Al. (2016). C++ in 24 Hours, Sams Teach Yourself (6th Edition).Sams Publishing
 McGrath, M. (2017). C++ programming in easy steps (5th ed.). Warwickshire, United Kingdom: Easy
Steps Limited
 Tale, T. (2016). C++: The Ultimate Beginners Guide to C++ Programing. CreateSpace Independent
Publishing Platform
 http://cs.uno.edu/~jaime/Courses/2025/devCpp2025Instructions.html

RUBRIC:

Criteria 4 3 2 1 Score
A completed
A completed solution is An incomplete
A completed
solution is implemented solution is
solution runs
tested and runs on the required implemented
without errors.
but does not platform, and on the required
It meets all the
meet all the uses the platform. It
specifications
specifications compiler does not
and works for
nd/or work for specified. It compile and/or
all test data.
all test data. runs, but has run.
Solution(x5) logical errors.

CCS0003L-Computer Programming 1 Page 15 of 16


The program Not all of
Few of the
The program design the selected
selected
design uses generally uses structures are
structures are
appropriate appropriate appropriate.
appropriate.
structures. The structures. Some of the
Program
overall program Program program
elements are
design is elements elements are
not well
appropriate. exhibit good appropriately
Program designed.
design. designed.
Design(x3)

All required There are


All required
parts of the few parts of Most of the
parts in the
document are the document parts of the
document are
complete and are missing document are
present and
correct(code, but the rest missing and
correct but not
output of are complete incorrect.
Completeness complete.
screenshots) and correct.
of
Document(x2)
Total

CCS0003L-Computer Programming 1 Page 16 of 16

You might also like