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

Loops Problem

The document contains a series of C programming tasks that involve computing sums and displaying patterns. It includes programs for calculating the sum of natural numbers, odd natural numbers, and harmonic series, as well as generating patterns with asterisks and numbers. Each task is accompanied by expected outputs based on provided test data.

Uploaded by

kushagra dwivedi
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)
7 views2 pages

Loops Problem

The document contains a series of C programming tasks that involve computing sums and displaying patterns. It includes programs for calculating the sum of natural numbers, odd natural numbers, and harmonic series, as well as generating patterns with asterisks and numbers. Each task is accompanied by expected outputs based on provided test data.

Uploaded by

kushagra dwivedi
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

1) Write a C program to compute the sum of the first 10 natural numbers.

Expected Output :

The first 10 natural number is :


1 2 3 4 5 6 7 8 9 10
The Sum is : 55

2) Write a program in C to display n terms of natural numbers and their sum.

Test Data : 7
Expected Output :
The first 7 natural number is :
1234567
The Sum of Natural Number upto 7 terms : 28

3) Write a C program to display the n terms of odd natural numbers and their
sum.

Test Data
Input number of terms : 10
Expected Output :
The odd numbers are :1 3 5 7 9 11 13 15 17 19
The Sum of odd Natural Number upto 10 terms : 100

4) Write a program in C to display a pattern like a right angle triangle using an


asterisk.

The pattern like :


*
**
***
****
5) Write a C program to display a pattern like a right angle triangle with a
number.

The pattern like :


1
12
123
1234
6) Write a program in C to make a pyramid pattern with numbers increased by
1.
1
2 3
4 5 6
7 8 9 10

7) Write a program in C to find the sum of the series [ 1-X^2/2!+X^4/4!- .........].

Test Data :
Input the Value of x :2
Input the number of terms : 5
Expected Output :
the sum = -0.415873
Number of terms = 5
value of x = 2.000000

8) Write a program in C to display the n terms of a harmonic series and their


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

Test Data :
Input the number of terms : 5
Expected Output :
1/1 + 1/2 + 1/3 + 1/4 + 1/5 +
Sum of Series upto 5 terms : 2.283334

You might also like