[go: up one dir, main page]

0% found this document useful (0 votes)
55 views9 pages

Laboratory Report 14

The document is a laboratory report for a Computer Fundamentals and Programming course. It includes programs using for, while, and do-while loops to output various patterns of numbers and characters. The programs for each loop type are provided, along with screenshots of the outputs. The report documents code snippets that use looping statements to print letter patterns A through F as instructed in the objectives.

Uploaded by

nairbatnabam
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 views9 pages

Laboratory Report 14

The document is a laboratory report for a Computer Fundamentals and Programming course. It includes programs using for, while, and do-while loops to output various patterns of numbers and characters. The programs for each loop type are provided, along with screenshots of the outputs. The report documents code snippets that use looping statements to print letter patterns A through F as instructed in the objectives.

Uploaded by

nairbatnabam
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/ 9

PANGASINAN STATE UNIVERSITY

URDANETA CITY CAMPUS


COLLEGE OF ENGINEERING AND ARCHITECTURE
DEPARTMENT OF MECHANICAL ENGINEERING
ACADEMIC YEAR 2023-2024, FIRST SEMESTER

LABORATORY REPORT
IN
COMPUTER FUNDAMENTALS AND
PROGRAMMING

Submitted by: Submitted to:


Mabanta Brian Engr. Miguel Albert D. Calizar
2 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

LABORATORY ACTIVITY NO. 14.1


Looping Statements Programming Activity
(For Loop)

OBJECTIVE: To create a program that uses for loop.

PROCEDURE: Using for loop, create a program that will provide the following outputs:

a. b.

PROGRAM: (Paste here your line of codes)

For letter A

#include <iostream>

#include <iomanip>

int main() {

for (int i = 0; i < 5; ++i) {

for (int k = 0; k < i; ++k) { std::cout << " ";

for (int j = i + 1; j <= 5; ++j) { std::cout << j;

std::cout << std::endl;

return 0;

For letter B

#include <iostream>

int main() {

PANGASINAN STATE REGION’S PREMIER UNIVERSITY


3 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

for (int i = 1; i <= 5; ++i) {

for (int j = 0; j < i; ++j) { std::cout << i;

std::cout << std::endl;

return 0;

OUTPUT: (Screenshot your final output)

CONCLUSION:

PANGASINAN STATE REGION’S PREMIER UNIVERSITY


4 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

LABORATORY ACTIVITY NO. 14.2


Looping Statements Programming Activity
(While Loop)

OBJECTIVE: To create a program that uses while loop.

PROCEDURE: Using while loop, create a program that will provide the following outputs:

c. d.

PROGRAM: (Paste here your line of codes)

For letter c

#include <iostream>

int main() { int row = 1;

while (row <= 5) {

int spaceCount = 0; while (spaceCount < row - 1) { std::cout << " ";

++spaceCount;

int number = row; while (number <= 5) { std::cout << number;

++number;

PANGASINAN STATE REGION’S PREMIER UNIVERSITY


5 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

std::cout << std::endl;

++row;

return 0;

For letter D

#include <iostream>

int main() { int row = 1;

while (row <= 5) {

int count = 1; while (count <= row) { std::cout << row;

++count;

std::cout << std::endl;

++row;

return 0;

OUTPUT: (Screenshot your final output)

PANGASINAN STATE REGION’S PREMIER UNIVERSITY


6 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

CONCLUSION:

LABORATORY ACTIVITY NO. 14.3


Looping Statements Programming Activity
(Do…While Loop)

OBJECTIVE: To create a program that uses do…while loop.

PANGASINAN STATE REGION’S PREMIER UNIVERSITY


7 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

PROCEDURE: Using do…while loop, create a program that will provide the following outputs:

e. f.

PROGRAM: (Paste here your line of codes)

FOR LETTER E:

#include <iostream>

int main() { int row = 1;

do {

int spaceCount = 0;

do { std::cout << "";

++spaceCount;

} while (spaceCount < row - 1);

int number = 1;

do { if (number >= row) { std::cout << number;

} else { std::cout << " ";

++number;

} while (number <= 5);

std::cout << std::endl; ++row;

} while (row <= 5);

return 0;

For letter F

#include <iostream>

int main() { int row = 1;

PANGASINAN STATE REGION’S PREMIER UNIVERSITY


8 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

do {

int count = 1; do { std::cout << row; ++count;

} while (count <= row);

std::cout << std::endl; ++row;

} while (row <= 5);

return 0;

CONCLUSION:

PANGASINAN STATE REGION’S PREMIER UNIVERSITY


9 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

PANGASINAN STATE REGION’S PREMIER UNIVERSITY

You might also like