Starting Vocational Training From 1-May-2024 Get Detail


C language

Loop
1.

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


Solution
2.

 Write a C programming that accepts principal amount, rate of interest and days for a loan and calculate the simple interest for the loan, using the following formula.
interest = principal * rate * days / 365.
Sample Input:
10000
.1
365
0
Sample Output:
Input loan amount (0 to quit): Input interest rate: Input term of the loan in days: The interest amount is $1000.00
Input loan principal_amt (0 to quit):


Solution
3.

Write a program in C 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


???????


Solution
4.

Write a program in C to display the n terms of square natural number 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


???????


Solution
5.

Write a program in C to find the sum of the series [ x - x^3 + x^5 + ......]. 
Test Data : 
Input the value of x :2 
Input number of terms : 5
Expected Output :
The values of the series: 

-8 
32 
-128 
512 
The sum = 410


Solution
6.

Write a program in C to display the sum of the series [ 1+x+x^2/2!+x^3/3!+....]. 
Test Data : 
Input the value of x :3 
Input number of terms : 5 
Expected Output :
The sum is : 16.375000 
???????


Solution
7.

Write a program in C to print the Floyds Triangle. 

1

01

101

0101

10101


Solution
8.

Write a program in C to display the sum of the series [ 9 + 99 + 999 + 9999 ...]. 
Test Data : 
Input the number or terms :5 
Expected Output :
9 99 999 9999 99999 
The sum of the saries = 111105


???????


Solution
9.

Write 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
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


Solution
10.

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


???????


Solution
11.

Write a program in C to display the n terms of even natural number and their sum. 
Test Data :
Input number of terms : 5 
Expected Output : 
The even numbers are :2 4 6 8 10 
The Sum of even Natural Number upto 5 terms : 30


???????


Solution
12.

Write a C program to calculate the factorial of a given number. 
Test Data :
Input the number : 5 
Expected Output : 
The Factorial of 5 is: 120 


???????


Solution
13.

Write a program in C to make such a pattern like a pyramid with numbers increased by 1. 

   1

  2 3

 4 5 6

7 8 9 10


Solution
14.

Write a program in C to make such a pattern like right angle triangle with number increased by 1. 

The pattern like :

   1

   2 3

   4 5 6

   7 8 9 10


Solution
15.

Write a program in C to make such a pattern like right angle triangle with a number which will repeat a number in a row. 

The pattern like :

 1

 22

 333

 4444


Solution
16.

Write a program in C to display the pattern like right angle triangle with a number. 

The pattern like :

1

12

123

1234


Solution
17.

Write a program in C to display the n terms of odd natural number 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 


???????


Solution
18.

Write a program in C to display the multipliaction table vertically from 1 to n. 
Test Data :
Input upto the table number starting from 1 : 8 
Expected Output : 
Multiplication table from 1 to 8 
1x1 = 1, 2x1 = 2, 3x1 = 3, 4x1 = 4, 5x1 = 5, 6x1 = 6, 7x1 = 7, 8x1 = 8 
... 
1x10 = 10, 2x10 = 20, 3x10 = 30, 4x10 = 40, 5x10 = 50, 6x10 = 60, 7x10 = 70, 8x10 = 80 


???????


Solution
19.

Write a program in C to display the multiplication table of a given integer. 
Test Data :
Input the number (Table to be calculated) : 15 
Expected Output : 
15 X 1 = 15 
...
... 
15 X 10 = 150


???????


Solution
20.

Write a program in C to read 10 numbers from keyboard and find their sum and average. 
Test Data :
Input the 10 numbers : 
Number-1 :2 
... 
Number-10 :2 
Expected Output : 
The sum of 10 no is : 55 
The Average is : 5.500000


Solution
21.
22.

Write a program in C to display n terms of natural number and their sum.
Test Data : 7 
Expected Output : 
The first 7 natural number is : 
1 2 3 4 5 6 7 
The Sum of Natural Number upto 7 terms : 28 



Solution
23.

Write a C program to find the sum of 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


???????


Solution
24.
25.

Write a program in C to display the first 10 natural numbers. 
Expected Output : 1 2 3 4 5 6 7 8 9 10


Solution