Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.a program in C++ to find the first 10 natural numbers. .. Sample output: The natural numbers are: 1 2 3 4 5 6 7

1.a program in C++ to find the first 10 natural numbers. ..

Sample output:

The natural numbers are:

1 2 3 4 5 6 7 8 9 10

Next.

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

Sample Output:

Find the first 10 natural numbers:

---------------------------------------

The natural numbers are:

1 2 3 4 5 6 7 8 9 10

The sum of first 10 natural numbers: 55

Next.

3.a program in C++ to display n terms of natural number and their sum. ..

Sample Output:

Input a number of terms: 7

The natural numbers upto 7th terms are:

1 2 3 4 5 6 7

The sum of the natural numbers is: 28

Next.

4.a program in C++ to find the perfect numbers between 1 and 500. ..

The perfect numbers between 1 to 500 are:

6

28

496

Next.

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

Sample Output:

Input a number to check prime or not: 13

The entered number is a prime number.

Next.

6.a program in C++ to find prime number within a range. ..

Input number for starting range: 1

Input number for ending range: 100

The prime numbers between 1 and 100 are:

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

The total number of prime numbers between 1 to 100 is: 25

Next.

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

Sample output:

Input a number to find the factorial: 5

The factorial of the given number is: 120

Next.

8.a program in C++ to find the last prime number occur before the entered number. ..

Sample Output:

Input a number to find the last prime number occurs before the number: 50

47 is the last prime number before 50

Next.

9.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

Next.

10.a program in C++ to find the sum of digits of a given number. ..

Sample Output:

Input a number: 1234

The sum of digits of 1234 is: 10

Next.

11.a program in C++ to find the sum of the series 1 + 1/2^2 + 1/3^3 + ..+ 1/n^n. ..

Sample Output:

Input the value for nth term: 5

1/1^1 = 1

1/2^2 = 0.25

1/3^3 = 0.037037

1/4^4 = 0.00390625

1/5^5 = 0.00032

The sum of the above series is: 1.29126

Next.

12.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

The sum of the above series is: 55

Next.

13.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

Next.

14.a program in C++ to find the sum of series 1 - X^2/2! + X^4/4!-.... upto nth term. ..

Sample Output:

Input the value of X: 3

Input the value for nth term: 4

term 1 value is: 1

term 2 value is: -4.5

term 3 value is: 3.375

term 4 value is: -1.0125

The sum of the above series is: -1.1375

Next.

15.a program in C++ to asked user to input positive integers to process count, maximum, minimum, and average or terminate the process with -1. ..

Sample Output:

Your input is for termination. Here is the result below:

Number of positive integers is: 4

The maximum value is: 9

The minimum value is: 3

The average is 6.00

Next.

16.a program in C++ to list non-prime numbers from 1 to an upperbound. ..

Sample Output:

Input the upperlimit: 25

The non-prime numbers are:

4 6 8 9 10 12 14 15 16 18 20 21 22 24 25

Next.

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

Sample Output:

Print a pattern like square with # character:

--------------------------------------------------

Input the number of characters for a side: 4

# # # #

# # # #

# # # #

# # # #

Next.

18.a program in C++ to display the cube of the number upto given 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

Next.

19.a program in C++ to display the multiplication table vertically from 1 to n. ..

Sample Output:

Input the number upto: 5

Multiplication table from 1 to 5

1x1=1 2x1=2 3x1=3 4x1=4 5x1=5

1x2=2 2x2=4 3x2=6 4x2=8 5x2=10

1x3=3 2x3=6 3x3=9 4x3=12 5x3=15

1x4=4 2x4=8 3x4=12 4x4=16 5x4=20

1x5=5 2x5=10 3x5=15 4x5=20 5x5=25

1x6=6 2x6=12 3x6=18 4x6=24 5x6=30

1x7=7 2x7=14 3x7=21 4x7=28 5x7=35

1x8=8 2x8=16 3x8=24 4x8=32 5x8=40

1x9=9 2x9=18 3x9=27 4x9=36 5x9=45

1x10=10 2x10=20 3x10=30 4x10=40 5x10=50

Next.

20.a program in C++ to display the n terms of odd natural number and their sum. ..

Sample Output:

Input number of terms: 5

The odd numbers are: 1 3 5 7 9

The Sum of odd Natural Numbers upto 5 terms: 25

Next.

21.a program in C++ to display the n terms of even natural number and their sum. ..

Sample Output:

Input number of terms: 5

The even numbers are: 2 4 6 8 10

The Sum of even Natural Numbers upto 5 terms: 30

Next.

22.a program in C++ to display the n terms of harmonic series and their sum. ..

1 + 1/2 + 1/3 + 1/4 + 1/5 ... 1/n terms

Sample Output:

Input number of terms: 5

1/1 + 1/2 + 1/3 + 1/4 + 1/5

The sum of the series upto 5 terms: 2.28333

Next.

23.a program in C++ to display the sum of the series [ 9 + 99 + 999 + 9999 ...]. ..

Sample Output:

Input number of terms: 5

9 99 999 9999 99999

The sum of the sarise = 111105

Next.

24.a program in C++ to display the sum of the series [ 1+x+x^2/2!+x^3/3!+....]. ..

Sample Output:

Input the value of x: 3

Input number of terms: 5

The sum is : 16.375

Next.

25.a program in C++ to find the sum of the series [ x - x^3 + x^5 + ......]. ..

Sample Output:

Input the value of x: 2

Input number of terms: 5

The values of series:

2

-8

32

-128

512

The sum of the series upto 5 term is: 410

Next.

26.a program in C++ to find the sum of the series 1 +11 + 111 + 1111 + .. n terms. ..

Sample Output:

Input number of terms: 5

1 + 11 + 111 + 1111 + 11111

The sum of the series is: 12345

Next.

27.a program in C++ to display the first n terms of Fibonacci series.

Sample Output:

Input number of terms to display: 10

Here is the Fibonacci series upto to 10 terms:

0 1 1 2 3 5 8 13 21 34

28.a program in C++ to find the number and sum of all integer between 100 and 200 which are divisible by 9.

Sample Output:

Numbers between 100 and 200, divisible by 9:

108 117 126 135 144 153 162 171 180 189 198

The sum : 1683

29.a program in C++ to find LCM of any two numbers using HCF.

Sample Output:

Input 1st number for LCM: 15

Input 2nd number for LCM: 25

The LCM of 15 and 25 is: 75

30.a program in C++ to display the number in reverse order. ..

Sample Output:

Input a number: 12345

The number in reverse order is : 54321

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Why is it important for leaders to demonstrate ethical conduct?

Answered: 1 week ago