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

Laboratory Report 14.2

This document is a laboratory report submitted by a student for a Computer Fundamentals and Programming course. It details programming activities using different looping statements in C++ like for, while, and do-while loops. The student created programs that output patterns using these different loops. Screenshots of the output of the programs are provided. The report concludes the laboratory activities on looping statements.

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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views9 pages

Laboratory Report 14.2

This document is a laboratory report submitted by a student for a Computer Fundamentals and Programming course. It details programming activities using different looping statements in C++ like for, while, and do-while loops. The student created programs that output patterns using these different loops. Screenshots of the output of the programs are provided. The report concludes the laboratory activities on looping statements.

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

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>

PANGASINAN STATE UNIVERSITY REGION’S PREMIER UNIVERSITY OF CHOICE


3 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

int main() {

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 UNIVERSITY REGION’S PREMIER UNIVERSITY OF CHOICE


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;

PANGASINAN STATE UNIVERSITY REGION’S PREMIER UNIVERSITY OF CHOICE


5 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

++number;

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 UNIVERSITY REGION’S PREMIER UNIVERSITY OF CHOICE


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 UNIVERSITY REGION’S PREMIER UNIVERSITY OF CHOICE


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 UNIVERSITY REGION’S PREMIER UNIVERSITY OF CHOICE


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 UNIVERSITY REGION’S PREMIER UNIVERSITY OF CHOICE


9 LABORATORY REPORT BS MECHANICAL ENGINEERING
COMPUTER FUNDAMENTALS AND PROGRAMMING

PANGASINAN STATE UNIVERSITY REGION’S PREMIER UNIVERSITY OF CHOICE

You might also like