Mastering loops

1.Printing stars

using for loop

using while loop

using do while loop

5 stars in a line

2. Finding sum of first N numbers

3. Finding factorial

4. Getting Y or N option from user

while loop

for loop

do while loop

5. max element in an array

6. reverse a string

EXERCISES

  1. Find the number of digits of a number
  2. Find the factors of a number
  3. Print Fibonacci series upto n terms
  4. count the number of words in a string
  5. convert input decimal number into binary

 

Loop control statements

1. Prime Number

2. Smallest multiple of 7 greater than n

Exercise
1. Find the biggest square number less than N.
2. Find the index of an element in an array. Output should be -1 if not found.

3. Copy positive elements from one array to another array

4. Loop using goto

Nested loops
1. Basic pattern

2.List of Prime Numbers

3.Selection Sort

4.Matrix Multiplication