Programming Fundamentals Lab 07 (Nested Loops)
Programming Fundamentals Lab 07 (Nested Loops)
Programming Fundamentals Lab 07 (Nested Loops)
Lab Instructors:
Ahmad Abduhu
#include<iostream>
int main(){
inti,j,k;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
cout<<i+j<<endl;
} }
return 0;
#include<iostream>
using namespace std;
int main(){
int i = 0;
int j = 0;
while(i < 10){
cout<<"i:"<< i<<endl;
while(j < 10){
cout<<"j:"<< j<<endl;
j++;
}
i++;
}
}
Lab Tasks
Task 1:
Write a program that inputs the value of x and range. Its then calculates and prints the sum of the
following series:
1 + 1/x + 1/x^2+1/x^3....
Task 2:
Write a program that inputs the height of triangle and displays a triangle of characters. For
example, if the user enters 5 it displays the following:
Enter the height of the triangle:
A
BC
DEF
GHIJ
KLMNO
PQRS
TUV
WX
Y
Task 3:
Write a program to print the following triangle patterns on console
Task 4:
Write a program to print all prime numbers between the range taken from the user. (Ask the user to
enter starting and ending numbers).
Task 5:
Write a program to print the multiplication table of the number entered by the user. The table should
get displayed in the following form.
29 * 1 = 29
29 * 2 = 58
29 * 3 = 87
.
.
.
29 * 10 = 290