[go: up one dir, main page]

0% found this document useful (0 votes)
11 views17 pages

For While Dowhile

Programming

Uploaded by

areeqasarim468
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)
11 views17 pages

For While Dowhile

Programming

Uploaded by

areeqasarim468
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/ 17

1

LOOPS (FOR | WHILE | DO-WHILE)


For Loop Tasks (1-33)

Task 1: Print numbers from 1 to N using a for loop


Objective: Learn how to use a for loop to print numbers from 1 to a given number N.
Task: Input a number N and print all numbers from 1 to N.
Logic: Use a for loop to iterate from 1 to N and print each number.

Task 2: Sum of first N natural numbers


Objective: Calculate the sum of the first N natural numbers using a for loop.
Task: Input a number N and calculate the sum of the first N natural numbers.
Logic: Initialize a variable sum = 0 and use a for loop to add each number from 1 to N.

Task 3: Print the multiplication table of a number


Objective: Print the multiplication table of a given number using a for loop.
Task: Input a number n and print its multiplication table from 1 to 10.
Logic: Use a for loop to multiply n by numbers from 1 to 10 and print the result.

Task 4: Print a pattern of stars in a square shape


Objective: Print a square-shaped pattern of stars using a for loop.
Task: Input a number N and print a square of stars of size N.
Logic: Use two nested for loops—one for rows and one for columns—to print stars in a square
pattern.

Task 5: Find the factorial of a number using a for loop


Objective: Calculate the factorial of a given number using a for loop.
Task: Input a number n and calculate n!.
Logic: Initialize fact = 1 and use a for loop to multiply fact by each number from 1 to n.
2

Task 6: Print Fibonacci series up to N terms


Objective: Print the Fibonacci series up to N terms using a for loop.
Task: Input a number N and print the first N terms of the Fibonacci series.
Logic: Initialize first = 0, second = 1, and use a for loop to calculate and print the next term in
the sequence.

Task 7: Check if a number is prime using a for loop


Objective: Check whether a given number is prime using a for loop.
Task: Input a number n and check if it is a prime number.
Logic: Use a for loop to check if the number is divisible by any number between 2 and sqrt(n).

Task 8: Sum of digits of a number


Objective: Calculate the sum of digits of a given number using a for loop.
Task: Input a number n and calculate the sum of its digits.
Logic: Use a for loop to extract each digit of n using modulo and add it to the sum.

Task 9: Reverse a number using a for loop


Objective: Reverse the digits of a given number using a for loop.
Task: Input a number n and reverse its digits.
Logic: Use a for loop to extract each digit and build the reversed number by multiplying by 10.

Task 10: Print prime numbers in a given range using a for loop
Objective: Print all prime numbers in a given range using a for loop.
Task: Input two numbers start and end, and print all prime numbers between them.
Logic: Use a nested for loop to check for primes in the range and print them.

Task 11: Calculate the sum of even numbers from 1 to N


Objective: Find the sum of even numbers from 1 to N using a for loop.
Task: Input a number N and calculate the sum of all even numbers from 1 to N.
Logic: Use a for loop to check if the number is even and add it to the sum.

Task 12: Print an inverted triangle pattern using stars


Objective: Print an inverted triangle pattern using stars.
3

Task: Input a number N and print an inverted right triangle of stars of size N.
Logic: Use a for loop to print stars, reducing the number of stars each row.

Task 13: Calculate the sum of odd numbers from 1 to N


Objective: Find the sum of odd numbers from 1 to N using a for loop.
Task: Input a number N and calculate the sum of all odd numbers from 1 to N.
Logic: Use a for loop to check if the number is odd and add it to the sum.

Task 14: Print a right-angle triangle pattern with numbers


Objective: Print a right-angle triangle pattern using numbers.
Task: Input a number N and print a right-angle triangle of numbers.
Logic: Use a for loop to print numbers in a right-angle triangle shape.

Task 15: Print a pyramid pattern using stars


Objective: Print a pyramid pattern using stars using a for loop.
Task: Input a number N and print a pyramid of stars.
Logic: Use two for loops—one for spaces and one for stars—to print each row of the pyramid.

Task 16: Calculate the product of all even numbers from 1 to N


Objective: Find the product of all even numbers from 1 to N.
Task: Input a number N and calculate the product of all even numbers from 1 to N.
Logic: Use a for loop to multiply the even numbers and keep a running product.

Task 17: Print a half-pyramid pattern of numbers


Objective: Print a half-pyramid pattern using numbers.
Task: Input a number N and print a half-pyramid pattern using numbers.
Logic: Use a for loop to print each row with increasing numbers.

Task 18: Check if a number is a perfect square using a for loop


Objective: Check whether a number is a perfect square using a for loop.
Task: Input a number n and check if it is a perfect square.
Logic: Loop through numbers from 1 to sqrt(n) and check if the square of any number is equal
to n.
4

Task 19: Print all multiples of a number up to N


Objective: Print all multiples of a number up to N using a for loop.
Task: Input a number n and print all multiples of n up to N.
Logic: Use a for loop to print multiples of n by incrementing n at each step.

Task 20: Find the sum of first N even numbers


Objective: Calculate the sum of the first N even numbers using a for loop.
Task: Input a number N and calculate the sum of the first N even numbers.
Logic: Use a for loop to add each even number until N even numbers are summed.

Task 21: Print a star pattern in the shape of a diamond


Objective: Print a diamond-shaped star pattern.
Task: Input a number N and print a diamond pattern using stars.
Logic: Use a for loop to print stars in a diamond shape with spaces in each row.

Task 22: Find the number of divisors of a number using a for loop
Objective: Find how many divisors a number has using a for loop.
Task: Input a number n and calculate how many divisors n has.
Logic: Use a for loop to check each number from 1 to n if it divides n without a remainder.

Task 23: Find the sum of all elements in an array


Objective: Calculate the sum of all elements in an array using a for loop.
Task: Input an array and calculate the sum of all elements.
Logic: Use a for loop to iterate through each element of the array and add them to a sum
variable.

Task 24: Print the reverse of an array


Objective: Reverse the order of elements in an array using a for loop.
Task: Input an array and print its elements in reverse order.
Logic: Use a for loop to access the array elements in reverse index order and print them.
5

Task 25: Find the largest element in an array


Objective: Find the largest element in an array using a for loop.
Task: Input an array and find the largest element.
Logic: Initialize a variable max = arr[0] and use a for loop to compare each element to find the
maximum value.

Task 26: Find the smallest element in an array


Objective: Find the smallest element in an array using a for loop.
Task: Input an array and find the smallest element.
Logic: Initialize a variable min = arr[0] and use a for loop to compare each element to find the
minimum value.

Task 27: Count the occurrences of an element in an array


Objective: Count how many times a specific element appears in an array using a for loop.
Task: Input an array and an element, and count how many times it appears.
Logic: Use a for loop to check each element of the array and increment the counter when a
match is found.

Task 28: Find the average of all elements in an array


Objective: Find the average of all elements in an array using a for loop.
Task: Input an array and calculate the average of its elements.
Logic: Use a for loop to sum all elements and then divide by the number of elements.

Task 29: Check if an array is sorted


Objective: Check if an array is sorted using a for loop.
Task: Input an array and check if it is sorted in ascending order.
Logic: Use a for loop to compare each element to the next one, ensuring that each is greater
than or equal to the previous element.

Task 30: Merge two sorted arrays into one sorted array
Objective: Merge two sorted arrays into one sorted array.
Task: Input two sorted arrays and merge them into a single sorted array.
Logic: Use two for loops to compare the elements of both arrays and add them in sorted order.
6

Task 31: Find the sum of diagonal elements in a matrix


Objective: Find the sum of diagonal elements in a 2D matrix.
Task: Input a square matrix and find the sum of its diagonal elements.
Logic: Use a for loop to access diagonal elements (matrix[i][i]) and sum them.

Task 32: Check if a number is a palindrome


Objective: Check whether a given number is a palindrome using a for loop.
Task: Input a number and check if it reads the same backward as forward.
Logic: Reverse the number and compare it to the original to determine if it is a palindrome.

Task 33: Generate the first N terms of an arithmetic progression


Objective: Generate the first N terms of an arithmetic progression.
Task: Input the first term a, the common difference d, and the number of terms N.
Logic: Use a for loop to generate and print the terms of the progression.

While Loop Tasks (34-66)

While Loop Tasks (34-66)

Task 34: Print numbers from 1 to N using a while loop


Objective: Learn to use a while loop to print numbers from 1 to N.
Task: Input a number N and print all numbers from 1 to N.
Logic: Initialize a counter variable i = 1 and use a while loop to print numbers until i equals N.

Task 35: Sum of first N natural numbers using a while loop


Objective: Calculate the sum of the first N natural numbers using a while loop.
Task: Input a number N and calculate the sum of the first N natural numbers.
Logic: Initialize sum = 0 and a counter variable i = 1, then use a while loop to add numbers to
the sum.
7

Task 36: Print the multiplication table of a number using a while loop
Objective: Print the multiplication table of a given number using a while loop.
Task: Input a number n and print its multiplication table from 1 to 10.
Logic: Initialize a counter variable i = 1 and use a while loop to multiply n by i and print the
result.

Task 37: Print a pattern of stars in a square shape using a while loop
Objective: Print a square-shaped pattern of stars using a while loop.
Task: Input a number N and print a square of stars of size N.
Logic: Use a while loop to print stars in each row and use another while loop to print N rows.

Task 38: Reverse a number using a while loop


Objective: Reverse the digits of a given number using a while loop.
Task: Input a number n and reverse its digits.
Logic: Use a while loop to extract the digits of n using modulo and build the reversed number.

Task 39: Find the factorial of a number using a while loop


Objective: Calculate the factorial of a given number using a while loop.
Task: Input a number n and calculate n!.
Logic: Initialize fact = 1 and a counter variable i = 1, then multiply fact by i in the while loop
until i reaches n.

Task 40: Check if a number is prime using a while loop


Objective: Check whether a given number is prime using a while loop.
Task: Input a number n and check if it is prime.
Logic: Use a while loop to check if n is divisible by any number between 2 and sqrt(n).

Task 41: Print Fibonacci series up to N terms using a while loop


Objective: Print the Fibonacci series up to N terms using a while loop.
Task: Input a number N and print the first N terms of the Fibonacci series.
Logic: Initialize first = 0, second = 1, and use a while loop to calculate and print the next term.
8

Task 42: Find the sum of digits of a number using a while loop
Objective: Calculate the sum of digits of a given number using a while loop.
Task: Input a number n and calculate the sum of its digits.
Logic: Use a while loop to extract each digit and add it to the sum using modulo.

Task 43: Print all prime numbers in a range using a while loop
Objective: Print all prime numbers in a given range using a while loop.
Task: Input two numbers start and end, and print all prime numbers between them.
Logic: Use a while loop to check for primes in the range and print them.

Task 44: Find the sum of all even numbers from 1 to N using a while loop
Objective: Calculate the sum of all even numbers from 1 to N using a while loop.
Task: Input a number N and calculate the sum of all even numbers from 1 to N.
Logic: Initialize i = 2 and use a while loop to sum even numbers from 2 to N.

Task 45: Print an inverted triangle pattern using stars


Objective: Print an inverted triangle pattern using stars.
Task: Input a number N and print an inverted triangle pattern of stars.
Logic: Use a while loop to print stars in each row, starting with N stars and decreasing by 1 on
each row.

Task 46: Find the number of digits in a number using a while loop
Objective: Find the number of digits in a given number using a while loop.
Task: Input a number n and find how many digits it has.
Logic: Use a while loop to divide the number by 10 until it becomes 0, counting the number of
divisions.

Task 47: Print the reverse of an array using a while loop


Objective: Reverse the order of elements in an array using a while loop.
Task: Input an array and print its elements in reverse order.
Logic: Use a while loop to access the array elements in reverse index order and print them.
9

Task 48: Find the largest element in an array using a while loop
Objective: Find the largest element in an array using a while loop.
Task: Input an array and find the largest element.
Logic: Initialize a variable max and use a while loop to compare each element to find the
maximum value.

Task 49: Count the number of even numbers in an array using a while loop
Objective: Count how many even numbers are present in an array using a while loop.
Task: Input an array and count the number of even numbers.
Logic: Use a while loop to check if each element is even and increment the counter
accordingly.

Task 50: Sum all elements of an array using a while loop


Objective: Calculate the sum of all elements in an array using a while loop.
Task: Input an array and calculate the sum of its elements.
Logic: Use a while loop to iterate through each element of the array and add them to the sum.

Task 51: Find the smallest element in an array using a while loop
Objective: Find the smallest element in an array using a while loop.
Task: Input an array and find the smallest element.
Logic: Initialize a variable min and use a while loop to compare each element to find the
minimum value.

Task 52: Find the sum of odd numbers in an array using a while loop
Objective: Find the sum of odd numbers in an array using a while loop.
Task: Input an array and calculate the sum of its odd numbers.
Logic: Use a while loop to check if each number is odd and add it to the sum.

Task 53: Print a half-pyramid pattern using stars with a while loop
Objective: Print a half-pyramid pattern using stars with a while loop.
Task: Input a number N and print a half-pyramid pattern of stars.
Logic: Use a while loop to print rows with increasing stars.
10

Task 54: Print numbers from N to 1 using a while loop


Objective: Print numbers from N to 1 using a while loop.
Task: Input a number N and print numbers in decreasing order from N to 1.
Logic: Initialize a counter i = N and use a while loop to print numbers and decrement i until it
reaches 1.

Task 55: Find the sum of diagonal elements in a matrix using a while loop
Objective: Find the sum of diagonal elements in a matrix.
Task: Input a square matrix and calculate the sum of its diagonal elements.
Logic: Use a while loop to access diagonal elements and sum them.

Task 56: Check if a number is a palindrome using a while loop


Objective: Check if a number is a palindrome using a while loop.
Task: Input a number n and check if it is a palindrome.
Logic: Reverse the number and compare it with the original number.

Task 57: Print prime numbers in a given range using a while loop
Objective: Print prime numbers in a given range using a while loop.
Task: Input two numbers start and end, and print all prime numbers in the range.
Logic: Use a while loop to check each number in the range for primality and print the prime
numbers.

Task 58: Count the number of odd numbers in an array using a while loop
Objective: Count the number of odd numbers in an array using a while loop.
Task: Input an array and count how many odd numbers it contains.
Logic: Use a while loop to check each element and increment the counter if the element is
odd.

Task 59: Find the average of elements in an array using a while loop
Objective: Calculate the average of elements in an array using a while loop.
Task: Input an array and calculate its average.
Logic: Sum the elements using a while loop and divide by the total number of elements.
11

Task 60: Print a diamond pattern using stars with a while loop
Objective: Print a diamond pattern using stars with a while loop.
Task: Input a number N and print a diamond-shaped pattern using stars.
Logic: Use while loops to print both the upper and lower parts of the diamond shape.

Do-While Loop Tasks (61-100)

Task 61: Print numbers from 1 to N using a do-while loop


Objective: Learn to use a do-while loop to print numbers from 1 to N.
Task: Input a number N and print all numbers from 1 to N.
Logic: Initialize a counter variable i = 1 and use a do-while loop to print numbers until i equals
N.

Task 62: Sum of first N natural numbers using a do-while loop


Objective: Calculate the sum of the first N natural numbers using a do-while loop.
Task: Input a number N and calculate the sum of the first N natural numbers.
Logic: Initialize sum = 0 and a counter variable i = 1, then use a do-while loop to add numbers
to the sum.

Task 63: Print the multiplication table of a number using a do-while loop
Objective: Print the multiplication table of a given number using a do-while loop.
Task: Input a number n and print its multiplication table from 1 to 10.
Logic: Initialize a counter variable i = 1 and use a do-while loop to multiply n by i and print the
result.

Task 64: Print a pattern of stars in a square shape using a do-while loop
Objective: Print a square-shaped pattern of stars using a do-while loop.
Task: Input a number N and print a square of stars of size N.
Logic: Use a do-while loop to print stars in each row and use another do-while loop to print N
rows.
12

Task 65: Reverse a number using a do-while loop


Objective: Reverse the digits of a given number using a do-while loop.
Task: Input a number n and reverse its digits.
Logic: Use a do-while loop to extract the digits of n using modulo and build the reversed
number.

Task 66: Find the factorial of a number using a do-while loop


Objective: Calculate the factorial of a given number using a do-while loop.
Task: Input a number n and calculate n!.
Logic: Initialize fact = 1 and a counter variable i = 1, then multiply fact by i in the do-while loop
until i reaches n.

Task 67: Check if a number is prime using a do-while loop


Objective: Check whether a given number is prime using a do-while loop.
Task: Input a number n and check if it is prime.
Logic: Use a do-while loop to check if n is divisible by any number between 2 and sqrt(n).

Task 68: Print Fibonacci series up to N terms using a do-while loop


Objective: Print the Fibonacci series up to N terms using a do-while loop.
Task: Input a number N and print the first N terms of the Fibonacci series.
Logic: Initialize first = 0, second = 1, and use a do-while loop to calculate and print the next
term.

Task 69: Find the sum of digits of a number using a do-while loop
Objective: Calculate the sum of digits of a given number using a do-while loop.
Task: Input a number n and calculate the sum of its digits.
Logic: Use a do-while loop to extract each digit and add it to the sum using modulo.

Task 70: Print all prime numbers in a range using a do-while loop
Objective: Print all prime numbers in a given range using a do-while loop.
Task: Input two numbers start and end, and print all prime numbers between them.
Logic: Use a do-while loop to check for primes in the range and print them.
13

Task 71: Find the sum of all even numbers from 1 to N using a do-while loop
Objective: Calculate the sum of all even numbers from 1 to N using a do-while loop.
Task: Input a number N and calculate the sum of all even numbers from 1 to N.
Logic: Initialize i = 2 and use a do-while loop to sum even numbers from 2 to N.

Task 72: Print an inverted triangle pattern using stars


Objective: Print an inverted triangle pattern using stars.
Task: Input a number N and print an inverted triangle pattern of stars.
Logic: Use a do-while loop to print stars in each row, starting with N stars and decreasing by 1
on each row.

Task 73: Find the number of digits in a number using a do-while loop
Objective: Find the number of digits in a given number using a do-while loop.
Task: Input a number n and find how many digits it has.
Logic: Use a do-while loop to divide the number by 10 until it becomes 0, counting the number
of divisions.

Task 74: Print the reverse of an array using a do-while loop


Objective: Reverse the order of elements in an array using a do-while loop.
Task: Input an array and print its elements in reverse order.
Logic: Use a do-while loop to access the array elements in reverse index order and print them.

Task 75: Find the largest element in an array using a do-while loop
Objective: Find the largest element in an array using a do-while loop.
Task: Input an array and find the largest element.
Logic: Initialize a variable max and use a do-while loop to compare each element to find the
maximum value.

Task 76: Count the number of even numbers in an array using a do-while loop
Objective: Count how many even numbers are present in an array using a do-while loop.
Task: Input an array and count the number of even numbers.
Logic: Use a do-while loop to check if each element is even and increment the counter
accordingly.
14

Task 77: Sum all elements of an array using a do-while loop


Objective: Calculate the sum of all elements in an array using a do-while loop.
Task: Input an array and calculate the sum of its elements.
Logic: Use a do-while loop to iterate through each element of the array and add them to the
sum.

Task 78: Find the smallest element in an array using a do-while loop
Objective: Find the smallest element in an array using a do-while loop.
Task: Input an array and find the smallest element.
Logic: Initialize a variable min and use a do-while loop to compare each element to find the
minimum value.

Task 79: Find the sum of odd numbers in an array using a do-while loop
Objective: Find the sum of odd numbers in an array using a do-while loop.
Task: Input an array and calculate the sum of its odd numbers.
Logic: Use a do-while loop to check if each number is odd and add it to the sum.

Task 80: Print a half-pyramid pattern using stars with a do-while loop
Objective: Print a half-pyramid pattern using stars with a do-while loop.
Task: Input a number N and print a half-pyramid pattern of stars.
Logic: Use a do-while loop to print rows with increasing stars.

Task 81: Print numbers from N to 1 using a do-while loop


Objective: Print numbers from N to 1 using a do-while loop.
Task: Input a number N and print numbers in decreasing order from N to 1.
Logic: Initialize a counter i = N and use a do-while loop to print numbers and decrement i until
it reaches 1.

Task 82: Find the sum of diagonal elements in a matrix using a do-while loop
Objective: Find the sum of diagonal elements in a matrix.
Task: Input a square matrix and calculate the sum of its diagonal elements.
Logic: Use a do-while loop to access diagonal elements and sum them.
15

Task 83: Check if a number is a palindrome using a do-while loop


Objective: Check if a given number is a palindrome using a do-while loop.
Task: Input a number and check if it reads the same forward and backward.
Logic: Reverse the number using a do-while loop and compare it to the original number.

Task 84: Count the occurrences of a specific number in an array using a do-while loop
Objective: Count how many times a specific number appears in an array.
Task: Input an array and a target number. Count how many times the target number appears in
the array.
Logic: Use a do-while loop to check each element of the array and increment the counter if
the element matches the target.

Task 85: Print a checkerboard pattern using a do-while loop


Objective: Print a checkerboard pattern using stars and spaces.
Task: Input the size of the board and print a checkerboard pattern.
Logic: Use a do-while loop to alternate between printing stars and spaces.

Task 86: Print Fibonacci series up to N terms using a do-while loop


Objective: Print the Fibonacci series up to N terms using a do-while loop.
Task: Input a number N and print the first N Fibonacci numbers.
Logic: Use the standard Fibonacci formula inside a do-while loop to print the sequence.

Task 87: Count the number of negative numbers in an array using a do-while loop
Objective: Count how many negative numbers are in an array.
Task: Input an array and count how many numbers are negative.
Logic: Use a do-while loop to check each element of the array for negativity.

Task 88: Find the sum of squares of all numbers from 1 to N using a do-while loop
Objective: Calculate the sum of squares of numbers from 1 to N.
Task: Input a number N and calculate the sum of squares of all numbers from 1 to N.
Logic: Use a do-while loop to square each number and add it to the sum.
16

Task 89: Check if a number is divisible by both 3 and 5 using a do-while loop
Objective: Check if a given number is divisible by both 3 and 5.
Task: Input a number and check if it is divisible by both 3 and 5.
Logic: Use a do-while loop to check divisibility with the modulo operator.

Task 90: Print an increasing triangle of numbers using a do-while loop


Objective: Print an increasing triangle pattern of numbers using a do-while loop.
Task: Input a number N and print an increasing triangle of numbers.
Logic: Use a do-while loop to print each row with increasing numbers.

Task 91: Reverse the words in a sentence using a do-while loop


Objective: Reverse the words in a given sentence using a do-while loop.
Task: Input a sentence and print the words in reverse order.
Logic: Use a do-while loop to split and reverse the words in the sentence.

Task 92: Find the sum of odd numbers between two given numbers using a do-while loop
Objective: Calculate the sum of odd numbers between two given numbers.
Task: Input two numbers and find the sum of odd numbers between them.
Logic: Use a do-while loop to check each number for oddness and sum them.

Task 93: Print a half-diamond pattern using numbers with a do-while loop
Objective: Print a half-diamond pattern using numbers.
Task: Input a number N and print a half-diamond pattern using numbers.
Logic: Use a do-while loop to print increasing numbers in the upper half and decreasing in the
lower half.

Task 94: Check if a number is a perfect square using a do-while loop


Objective: Check if a given number is a perfect square.
Task: Input a number and check if it is a perfect square.
Logic: Use a do-while loop to calculate the square root of the number and check if it is an
integer.
17

Task 95: Print a right-angled triangle pattern using stars with a do-while loop
Objective: Print a right-angled triangle pattern using stars.
Task: Input a number N and print a right-angled triangle of stars.
Logic: Use a do-while loop to print stars, increasing by one on each row.

Task 96: Print the sum of all multiples of 3 from 1 to N using a do-while loop
Objective: Calculate the sum of all multiples of 3 from 1 to N.
Task: Input a number N and calculate the sum of all multiples of 3.
Logic: Use a do-while loop to check each number for divisibility by 3 and sum them.

Task 97: Count the number of vowels in a string using a do-while loop
Objective: Count the number of vowels in a given string.
Task: Input a string and count the number of vowels it contains.
Logic: Use a do-while loop to iterate through the string and check for vowels.

Task 98: Print a diamond pattern using numbers with a do-while loop
Objective: Print a diamond pattern using numbers.
Task: Input a number N and print a diamond pattern using numbers.
Logic: Use a do-while loop to print both the upper and lower parts of the diamond with
numbers.

Task 99: Calculate the product of all even numbers from 1 to N using a do-while loop
Objective: Calculate the product of all even numbers from 1 to N.
Task: Input a number N and calculate the product of all even numbers from 1 to N.
Logic: Use a do-while loop to multiply even numbers and store the result.

Task 100: Print the factorial of numbers from 1 to N using a do-while loop
Objective: Print the factorial of all numbers from 1 to N.
Task: Input a number N and print the factorial for each number from 1 to N.
Logic: Use a do-while loop to calculate the factorial for each number and print it.

You might also like