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

3 G3 LAB Dec 02 2020

1. The document provides instructions and topics for Computing Fundamentals & Programming Laboratory Exercise-03 at Pakistan Institute of Engineering and Applied Sciences. 2. It covers nested loops and provides examples of nested for, while, and do-while loops. Within lab tasks involve writing programs to print patterns using loops. 3. Home tasks include writing programs to print Fibonacci series, various patterns, and compute mathematical functions like sin, cosine, and exponential series using loops and series formulas.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

3 G3 LAB Dec 02 2020

1. The document provides instructions and topics for Computing Fundamentals & Programming Laboratory Exercise-03 at Pakistan Institute of Engineering and Applied Sciences. 2. It covers nested loops and provides examples of nested for, while, and do-while loops. Within lab tasks involve writing programs to print patterns using loops. 3. Home tasks include writing programs to print Fibonacci series, various patterns, and compute mathematical functions like sin, cosine, and exponential series using loops and series formulas.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Pakistan Institute of Engineering and

Applied Sciences

Computing Fundamentals & Programming


Fall 2020
Laboratory Exercise-03

Date: DEC 02, 2020

Computing Fundamentals & Programming Lab 3


Instructions:

Any One Found


1. Using Mobile Without Permission Will Be Marked As Absent And 50% Marks Of This
Lab Will Be Deducted.

2. Copying Assignment / Using internet During Lab tasks and Marking Proxy will Lead you
to “F” Grade in the Lab. Be very Careful.

3. Use appropriate naming convention for variable name. e.g to calculate the sum of number
variable name can be sum, sum_of_number. Random variable names are not allowed.

4. Lab Tasks must also be submitted in report format too. Sample format is available on
below path. \\172.30.10.24\FacultyShare\Muhammad Yousaf Hamza
Dr\Public\1_CFP_Zero_Sem_2020_22\2_Lab_Assignments

5. Submission Deadline of Home Tasks of Lab 03 is Tuesday, 08-Dec-2020 (11:00 AM).


Please note date will not be extended.

6. Assignment Submission Path: \\172.30.10.2\Assignments\Applied Sciences


Dept\DPAM\Dr. Muhammad Yousaf Hamza\0_Zero_Lab_G2

7. Within Lab task must be submitted on below mentioned path till Wednesday, 02-Dec-
2020 (13:30PM)

8. Assignment Submission Path: \\172.30.10.2\Assignments\Applied Sciences


Dept\DPAM\Dr. Muhammad Yousaf Hamza\0_Zero_Lab_G2

9. Please follow following file names format for file submission:


DegreeName_TwoDigitSerialNumber__Full_Name_LabNo_WithinLab_DateOfSubmissio
n
DegreeName_TwoDigitSerialNumber__Full_Name_LabNo_HomeTasks_DateOfSubmissi
on
Example: Process_01_Abdul Aziz_LabNo1_WithinLab_Nov24_2020.

10. Please note that there is Non- Submission Important Practice Tasks section in this
lab manual, these tasks are not required to be submitted. These tasks are for
practice purpose only. Please note that these important task can be part of quizzes
and exams.

Computing Fundamentals & Programming Lab 3


Topics Covered
1. Nested Loop

Nested Loop

A loop inside another loop is called a nested loop. The depth of nested loop depends on the
complexity of a problem. We can have any number of nested loops as required. Consider a
nested loop where the outer loop runs n times and consists of another loop inside it. The inner
loop runs m times. Then, the total number of times the inner loop runs during the program
execution is n*m.

Syntax:

The syntax for a nested for loop statement in C is as follows −


for ( init; condition; increment ) {

for ( init; condition; increment ) {


statement(s);
}
statement(s);
}

The syntax for a nested while loop statement in C programming language is as follows −
while(condition) {

while(condition) {
statement(s);
}
statement(s);
}

The syntax for a nested do...while loop statement in C programming language is as follows −
do {
statement(s);

do {
statement(s);
}while( condition );

}while( condition );

Self-Acivity-Task-01

#include <stdio.h>
int main()
{
int i=1,j;
while (i <= 5)
{
j=1;
while (j <= i )
{
printf("%d ",j);
j++;
}
printf("\n");
i++;
}
Getchar();

Computing Fundamentals & Programming Lab 3


return 0;
}

Output:
1
12
123
1234
12345

Within Lab Task -01

Write a program in C to make a pattern like right angle triangle.

Sample Output:

5
44
333
2222
11111

Within Lab Task -02


C program to find sum of following series:
1 + 3^2/3^3 + 5^2/5^3 + 7^2/7^3 + ... till N terms

Home Tasks Section

Home Task 1

Write a program in C to display the first n terms of Fibonacci series. Your program may look like this
Number of terms to display: 10
Fibonacci series up to 10 terms: 0 1 1 2 3 5 8 13 21 34 .

Home Task 2
Write a program in C to print the following pattern.

Computing Fundamentals & Programming Lab 3


Home Task 3
Write a C program to print the following patterns.

Home Task 4

Print the following output using a C program.

Home Task 5
Write a program to compute the sin of x. The user should supply x and a positive integer n. We compute the
sin of x using the series and the computation should use all terms in the series up through the term involving
xn

Home Task 6
Write a program to compute the cosine of x. The user should supply x and a positive integer n. We compute
the cosine of x using the series and the computation should use all terms in the series up through the term
involving xn
cos x = 1 - x2/2! + x4/4! - x6/6! ..

Computing Fundamentals & Programming Lab 3


Non-Submission Important Practice Tasks

Important Practice Task 1


Write a program to compute the tan of x. The user should supply x and a positive integer n. We compute the
tan of x using the series and the computation should use all terms in the series up through the term involving
xn

Important Practice Task 2


Write a C program to print pascal triangle up to n rows using loop.

Important Practice Task 3


Write a C program to print the given X number pattern series using for loop.

Important Practice Task 4


Write a C program to print odd number pattern using loop.

Computing Fundamentals & Programming Lab 3


Important Practice Task 5

Write a C program to print the given triangle number pattern using 0, 1.

Important Practice Task 6

Write a C program to print the given number pattern using loop.

Important Practice Task 7

Write a C program to print the given number pattern using for loop.

Important Practice Task 8


Write a C program to print right arrow star pattern series using for loop.

Computing Fundamentals & Programming Lab 3


Important Practice Task 9
Write a C program to print the given half diamond star number pattern series using for loop.

Important Practice Task 10


Write a C program to evaluate exponential series upto limit n
Exponential series is of the form

e^x=1+x/1!+x^2/2!+x^3/3!+...x^n/n!

Important Practice Task 11

Write a program in C to print the following pattern.

Important Practice Task 12

Write a program in C to print the following pattern.

Computing Fundamentals & Programming Lab 3


Important Practice Task 13

Write a program in C to print the following pattern.

Important Practice Task 14

Try to modify the previous program such that the program prints the following pattern

Important Practice Task 15


Try to modify the previous program such that the program prints the following pattern

Computing Fundamentals & Programming Lab 3

You might also like