0% found this document useful (0 votes)
6 views

Assignment - Loops

Uploaded by

padamdamai888
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)
6 views

Assignment - Loops

Uploaded by

padamdamai888
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/ 3

1.

Write a program to display the cube of the number up to an


integer.
Test Data :
Input number of terms : 5
Expected Output :
Number is : 1 and cube of the 1 is :1
Number is : 2 and cube of the 2 is :8
Number is : 3 and cube of the 3 is :27
Number is : 4 and cube of the 4 is :64
Number is : 5 and cube of the 5 is :125

2. Write a program to display the multiplication table for a given


integer.
Test Data :
Input the number (Table to be calculated) : 15
Expected Output :
15 X 1 = 15
...
...
15 X 10 = 150

3. Write a program 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

4. Write a program that displays the n terms of square natural


numbers and their sum.
1 4 9 16 ... n Terms
Test Data :
Input the number of terms : 5
Expected Output :
The square natural upto 5 terms are :1 4 9 16 25
The Sum of Square Natural Number upto 5 terms = 55

5. Write a program to find the sum of the series 1 +11 + 111 +


1111 + .. n terms.
Test Data :
Input the number of terms : 5
Expected Output :
1 + 11 + 111 + 1111 + 11111
The Sum is : 12345

6. Write a program to display the first n terms of the Fibonacci


series.
Fibonacci series 0 1 2 3 5 8 13 .....
Test Data :
Input number of terms to display : 10
Expected Output :
Here is the Fibonacci series upto to 10 terms :
0 1 1 2 3 5 8 13 21 34

7. Write a program to display the number in reverse order.


Test Data :
Input a number: 12345
Expected Output :
The number in reverse order is : 54321
8. Write a program to check whether a number is a palindrome or
not.
Test Data :
Input a number: 121
Expected Output :
121 is a palindrome number.

Write a program to find the number and sum of all integers


between 100 and 200 which are divisible by 9.
Expected Output :
Numbers between 100 and 200, divisible by 9 :
108 117 126 135 144 153 162 171 180 189 198
The sum : 1683

Write a program to convert a decimal number into binary without


using an array.
Test Data :
Input a decimal number: 25
Binary number equivalent to said decimal number is:
0000000000000000000000000001 1001

Write a C program to convert a binary number into a decimal


number without using array, function and while loop.
Test Data :
Input a binary number :1010101
Expected Output :
The Binary Number : 1010101
The equivalent Decimal Number : 85

You might also like