Loop programming exercises and solutions in C++

Let us see a list of important Loop programming exercises and solutions in C++.

For loop

For loop is a methodology to use a piece of code again and again until the given condition remains true. The loop will terminate when the given condition is false.

For loop has three parts. Loop initialization, Condition, and increment or decrement of a loop.

  1. Program to find the length of a number in C++ (CPP).
  2. Program to find the square root of a number in C++
  3. Factorial Program in C, C++ (C Plus Plus, CPP) with flow chart
  4. Fibonacci Series Program in C++ and C with flowchart
  5. Palindrome Program in C, C++, C Plus Plus (CPP) with flow chart
  6. Program to the Print sum of the number of Series in C Plus Plus (CPP, C++) and C with Flowchart
  7. Programs to Find the Number of Vowels, Digits, Consonants, and White Spaces in a String with a flowchart
  8. Program in C++, C to display the reverse of a number with a flowchart
  9. Write a program that lets the user enter the total rainfall for each of the 12 months
  10. Write a C++ program to print a triangle of prime numbers up to a given number of lines of the triangle
  11. Write a C++ program to print all numbers between a and b (a and b inclusive) using for loops
  12. Write a simple C++ program to find the mean value

while loop

The while loop is a methodology to use a piece of code again and again until the given condition remains true. The loop will terminate when the given condition is false.

Just like for loop, the while loop has three parts. 1. Loop initialization, 2. Condition, and 3. increment or decrement of a loop.

  1. Program of the sum of all digits of a number in C, C Plus Plus (CPP, C++) with a flow chart
  2. converts a number into binary in C++ and C with a flowchart
  3. Program in C Plus Plus and C with an explanation to find the Greatest Common Division (GCD). Solution with flowchart
  4. C++ Program to convert Octal to decimal number using while loop
  5. Write a program using integers usernum and x as input, and output usernum divided by x four times.
  6. Write a C++ program to add two numbers without using the addition operator
  7. Write a C++ program that simulates the rolling of two dice

Do while loop

In Do, while loop, first one time we execute the do part of the loop, and then we check the condition. It means that if the condition is false then still do part execute one time.

  1. C++ Program to Display English Alphabets from  A-Z. Solution
  2. Write a program in C++ to display the multiplication table vertically from 1 to n. Solution
  3. C++ Program to Find the Sum of Digits of a Number – C++ Program. Solution
  4. Program in C++ to display the n terms of even natural number and their sum. Solution
  5. C++ program to find the sum of all integers between 100 and 200 which are divisible by 9. Solution
  6. Write a program in C++ to print Floyd’s Triangle. Solution
  7. C++ program to print pyramid patterns of numbers.  Solution
  8. C++ Program to display the n terms of odd natural number and their sum. Solution
  9. Convert a binary number to octal in C++. Solution
  10. C++ program to check whether a given number is a perfect number or not. Solution
  11. C++ program to find the HCF (Highest Common Factor) of two numbers. Solution
  12. Program in C++ to convert a decimal number into binary without using an array. Solution
  13. Program C++ to convert an octal number into binary. Solution
  14. Write a c program to find out the sum of an A.P. series. Solution
  15. Program in C++, C to display the reverse of a number with a flowchart. Solution
  16. Write the Octal to Decimal number program in C++. Solution
  17. C++ Program right angle triangle with a number that will repeat a number in a row. Solution
  18. C++ program to print rhombus or parallelogram star patterns. Solution
  19. Program in C++ to make a pattern like a pyramid with a number that will repeat the number in the same row. Solution
  20. Write a program in C++ to Check Whether a Number can be expressed as a Sum of Two Prime Numbers. Solution
  21. C++ program to print mirrored right triangle star pattern. Solution
  22. Decimal to octal number conversion program in C++. Solution
  23. C++ program to print a hollow square or rectangle star pattern. Solution
  24. C++ Program Sum of odd Natural Number. Solution
  25. The sum of the first 10 natural numbers program in C++. Solution

Comparison of Loops in C++(For, While, Do while loop )

Prefix and postfix

  1. Prefix and postfix increment and decrement in C++. Solution

Strings

Remove Whitespaces from the program

 

Arrays

Two’s complement of a binary number in C++

Pointers

Write a program in C++ to add two numbers using pointers

General Programs

Write a C++ program to Set Get Clear a particular bit in a given number

 

shamil memory table

C Language Programs

Write a c program to reverse a given word using a function

write a C program to sort a 1d array using a pointer by applying the bubble sort technique