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

PF LAB

The document contains three C++ programming tasks. Task 1.1 counts how many persons are aged between 50 and 60, Task 1.2 calculates the squares, cubes, and sums of five input numbers along with their grand total, and Task 1.3 finds the maximum value from ten input values. Each task includes user input and output statements for interaction.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

PF LAB

The document contains three C++ programming tasks. Task 1.1 counts how many persons are aged between 50 and 60, Task 1.2 calculates the squares, cubes, and sums of five input numbers along with their grand total, and Task 1.3 finds the maximum value from ten input values. Each task includes user input and output statements for interaction.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

PF LAB

NAME: MUNTAHA AFZAL


ROLL NUM: F2024105028

o TASK 1.1
#include <iostream>

using namespace std;

int main() {

int n, count = 0;

int ages[100];

cout << "Enter the number of persons required: ";

cin >> n;

cout << "Enter ages of " << n << " persons.\n";

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

cin >> ages[i];

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

if (ages[i] >= 50 && ages[i] <= 60) {

count++;
}

cout << count << " persons are between 50 and 60\n";

return 0;

o TASK 1.2
#include <iostream>

using namespace std;

int main() {

int numbers[5];

int squares[5];

int cubes[5];

int sums[5];

int grandTotal = 0;

cout << "Enter 5 numbers:\n";

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

cin >> numbers[i];

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

squares[i] = numbers[i] * numbers[i];

cubes[i] = numbers[i] * numbers[i] * numbers[i];


sums[i] = numbers[i] + squares[i] + cubes[i];

grandTotal += sums[i];

// Output results

cout << "numbers: ";

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

cout << numbers[i] << " ";

cout << "\nsquares: ";

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

cout << squares[i] << " ";

cout << "\ncubes: ";

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

cout << cubes[i] << " ";

cout << "\nsums: ";

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

cout << sums[i] << " ";

cout << "\nGrand total: " << grandTotal << endl;

return 0;

}
o TASK 1.3
#include <iostream>

using namespace std;

int main() {

int SIZE = 10;

int values[SIZE];

int maxValue;

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

cout << "Enter value: ";

cin >> values[i];

maxValue = values[0];

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

if (values[i] > maxValue) {

maxValue = values[i];

cout << "maximum value: " << maxValue << endl;

return 0;

You might also like