0% found this document useful (0 votes)
3 views2 pages

Repitition Statements

The document provides a series of C++ programming tasks, including finding the sum of the first 10 natural numbers, checking for prime numbers, calculating factorials, and finding the GCD of two numbers. It also includes programs to calculate specific series, print square patterns, and display cubes of numbers. Sample outputs are provided for each task to illustrate the expected results.

Uploaded by

muntahaimran709
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Repitition Statements

The document provides a series of C++ programming tasks, including finding the sum of the first 10 natural numbers, checking for prime numbers, calculating factorials, and finding the GCD of two numbers. It also includes programs to calculate specific series, print square patterns, and display cubes of numbers. Sample outputs are provided for each task to illustrate the expected results.

Uploaded by

muntahaimran709
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Single Loop

Write a program in C++ to find the sum of the first 10 natural numbers.

Write a program in C++ to display n terms of natural numbers and their sum.
Sample Output:
Input a number of terms: 7
The natural numbers upto 7th terms are:
1234567
The sum of the natural numbers is: 28

Write a program in C++ to check whether a number is prime or not.

Write a program in C++ to find the factorial of a number.

Write a program in C++ to find the Greatest Common Divisor (GCD) of two
numbers.
Sample Output:
Input the first number: 25
Input the second number: 15
The Greatest Common Divisor is: 5

Write a program in C++ to calculate the sum of the series (1*1) + (2*2) + (3*3) +
(4*4) + (5*5) + ... + (n*n).
Sample Output:
Input the value for nth term: 5
1*1 = 1
2*2 = 4
3*3 = 9
4*4 = 16
5*5 = 25

Write a program in C++ to calculate the series (1) + (1+2) + (1+2+3) + (1+2+3+4)
+ ... + (1+2+3+4+...+n).
Sample Output:
Input the value for nth term: 5
1=1
1+2 = 3
1+2+3 = 6
1+2+3+4 = 10
1+2+3+4+5 = 15
The sum of the above series is: 35

Write a program in C++ to print a square pattern with the # character.


Sample Output:
Print a pattern like square with # character:
--------------------------------------------------
Input the number of characters for a side: 4
####
####
####
####

Write a program in C++ to display the cube of the number up to an integer.


Sample Output:
Input the number of terms : 5
Number is : 1 and the cube of 1 is: 1
Number is : 2 and the cube of 2 is: 8
Number is : 3 and the cube of 3 is: 27
Number is : 4 and the cube of 4 is: 64
Number is : 5 and the cube of 5 is: 125

Write a C++ program to print all numbers between a and b (a and b inclusive) using
for loops

Nested Loops

You might also like