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

North South University Department of Electrical and Computer Engineering CSE 215L: Programming Language II Lab Lab

This document provides the objectives and tasks for a programming lab on conditional statements and loops. The lab includes: 1) Using a for loop to print random integers, 2) Printing a pattern using loops, 3) Using a while loop to print descending integers divisible by 8, 4) Checking if a random year is a leap year, 5) Printing a pattern using nested loops.

Uploaded by

Tasfiul Hedayet
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)
46 views

North South University Department of Electrical and Computer Engineering CSE 215L: Programming Language II Lab Lab

This document provides the objectives and tasks for a programming lab on conditional statements and loops. The lab includes: 1) Using a for loop to print random integers, 2) Printing a pattern using loops, 3) Using a while loop to print descending integers divisible by 8, 4) Checking if a random year is a leap year, 5) Printing a pattern using nested loops.

Uploaded by

Tasfiul Hedayet
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/ 1

North South University

Department of Electrical and Computer Engineering


CSE 215L: Programming Language II Lab

Lab – 3: Conditional Statement, Loop

Objective:
● To learn to use conditional statements (if, else, switch case)
● To learn the usage of loops (for, while, do-while)

1. Generate a random integer n between 5 and 20 (inclusive). Use for loop to print all integers
from 0 to n separated by a space. To generate a random integer between min and max range:

int n = (int)(min+Math.random()*(max-min+1))

Sample Output:
Random integer: 7
01234567
2. Print the following
12345
1234
123
12
1

3. Write a program which will use while loop to print all the integers between 100 and 150 which
are divisible by 8 in descending order.
Output: 144 136 128 120 112 104

4. Generate a random int between 1990 and 2020. Then print it check if it’s a leap year or not.
Note: A leap year must satisfy any or both of the following conditions:

Divisible by 400
Divisible by 4 and not divisible by 100
Sample output:
2015: false

5. Print the following pattern:


*
+++
*****
+++++++
*********

You might also like