0% found this document useful (0 votes)
5 views5 pages

Saad Abdullah Awan BCS243175 ITP LAB 7 Practice Task-1

Uploaded by

Abdul Rafay
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)
5 views5 pages

Saad Abdullah Awan BCS243175 ITP LAB 7 Practice Task-1

Uploaded by

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

Saad Abdullah Awan

[Date]

ITP Lab 7 Practice Task


Section 04
Practice Task 1

#include <iostream>

using namespace std;

int main() {

int rows = 5;

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

for (int j = 0; j < rows - i - 1; j++) {

cout << " ";

for (int k = 0; k < 2 * i + 1; k++) {

cout << "*";

cout << endl;

return 0;

}
Practice Task 2

#include <iostream>

using namespace std;

int main() {

int n = 5;

int num = 1;

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

for (int j = 1; j <= n - i; j++) {

cout << " ";

for (int j = 1; j <= 2 * i - 1; j++) {

cout << num << " ";

num++;

cout << endl;

for (int i = n - 1; i >= 1; i--) {

for (int j = 1; j <= n - i; j++) {

cout << " ";

for (int j = 1; j <= 2 * i - 1; j++) {

cout << num << " ";

num++;

cout << endl;

return 0;

}
Practice Task 3

#include <iostream>

using namespace std;

int main() {

int num;

int Prime = 1;

cout << "Enter a positive integer: ";

cin >> num;

if (num <= 1) {

Prime = 0;

else {

for (int i = 2; i * i <= num; i++) {

if (num % i == 0) {

Prime = 0;

break;

if (Prime) {

cout << num << " is a prime number." << endl;

else {

cout << num << " is not a prime number." << endl;

return 0;

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