Date post: | 17-Nov-2014 |
Category: |
Documents |
Upload: | kalpana-nagle |
View: | 26 times |
Download: | 4 times |
I. Introduction to “C” Programming
1. To convert Fahrenheit degrees into Centigrade and vice-versa.
Hint: F = 1.8 * C + 32.0, C = (F-32)/1.8
2. Write a program to find the sum and average of three numbers.
3. Write a program to find the distance for the given Speed and time.
4. To find the area of triangle given the three sides.
Formula:s(s-a)(s-b)(s-c) (s=(a+b+c)/2)
5. Write a program that a star as* *
* **
* * * *
6. To convert seconds into hours and minutes and seconds.
7. To convert days to months and days.
8. To find the area of the triangle given the base and height
9. Find out area and Volume of a Sphere?
10. Find the sum of n natural numbers.
11. Find out the total Mechanical Energy of a particle is given by e =mgh+1/2 mv2.
12. Given the coordinates of two points (x1, y1) and (x2, y2) write a program to find the
distance between these points.
13. Write a program to calculate simple interest and Total amount.
14. Write a C program that evaluates the following algebraic expressions after reading
necessary values from the user:
a. ax+b/ax-bb. 2.5 log x + cos 32 + |x2-y2| + v 2xy
15. If a five-digit number is input through the keyboard, write a program to reverse the
number.
16. If a four-digit number is input through the keyboard, write a program to obtain the
sum of the first and last digit of this number.
17. If a five-digit number is input through the keyboard, write a program to calculate the
sum of its digits.
Hint: Use the modulus operator ‘%’
Lab Programs
II. Decision Making and Branching
18. While purchasing certain items, a discount of 10% is offered if the quantity purchased
is more than 1000. If quantity and price per item are input through the keyboard,
write a program to calculate the total expenses.
19. The current year and the year in which the employee joined the organization are
entered through the keyboard. If the number of years for which the employee has
served the organization is greater than 3 then a bonus of Rs.2500/- is given to the
employee. If the years of service are not greater than 3, then the program should not
do anything.
20. If his basic salary is less than Rs.1500, then HRA = 10% of basic salary and DA =
90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA =
Rs. 500 and DA = 98% of basic salary. If the employee’s salary is input through the
keyboard write a program to find his gross salary.
21. A company insures its drivers in the following cases:
– If the driver is married– If the driver is unmarried, male & above 30 years of age.– If the driver is unmarried, female & above 25 years of age.
In all other cases the driver is not insured. If the marital status, sex and age of the
driver are the inputs, write a program to determine whether the driver is to be insured or
not.
22. Write a program to calculate the salary as per the following table:
Gender Years Qualifications SalaryMale >=10 Post-Graduate 15000
>=10 Graduate 10000<10 Post-Graduate 10000<10 Graduate 7000
Female >=10 Post-Graduate 12000>=10 Graduate 9000<10 Post-Graduate 10000<10 Graduate 6000
23. Write a program to find the roots of a quadratic equation for all cases.
d>0 The two roots are reald=0 Roots are equal and reald<0 Roots are imaginary
24. Display three numbers in ascending order using if-else statement.
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
2
Lab Programs
25. If cost price and selling price of an item is input through the keyboard, write a
program to determine whether the seller has made profit or incurred loss. Also
determine how much profit he made or loss he incurred.
26. If a five-digit number is input through the keyboard, write a program to obtain the
reversed number and to determine whether the original and reversed numbers are
equal or not.
27. Any character is entered through the keyboard; write a program to determine whether
the character entered is a capital letter, a small case letter, a digit or a special symbol.
28. Write a program to calculate income tax of an employee. If the income is upto Rs.
60,000/-, then tax is zero. If the income is upto Rs. 80,000/- then the tax is 15% of the
amount that is greater than Rs. 60,000/-. If the amount is greater than Rs.80,000/-,
then the tax is on Rs. 80,000/- plus 20% of the amount that is greater than Rs.
80,000/-.
29. Write a program to determine in which of the four quadrants an angle lies where.
0 <= angle <=360 degrees.
30. Calculate electric bill depending the following conditions
Consumption Units Rate of Charge0-200 Rs. 0.50 per unit201-400 Rs. 100 plus Rs.0.65 per unit excess of 200401-600 Rs. 230 plus Rs.0.80 per unit excess of 400601 and above Rs. 390 plus Rs.1.00 per unit excess of 600
31. Write a menu driven program which has following options:
a. Factorial of a numberb. Prime or notc. Odd or even
32. Enter the character print the corresponding color name using switch statement.
33. Enter the character print the corresponding day name using switch statement.
34. To print grade of a student using switch statement.
35. Read x and compute Y = 1 for x > 0
Y = 0 for x = 0
Y = -1 for x < 0
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
3
Lab Programs
36. A cloth show room has announced the following seasonal discounts on purchase of
items.
PURCHASE Discount (Percentage)
AMOUNT Mill Cloth Handloom Cloth
1-100 __ 5.0
101-200 5.0 7.5
201-300 7.5 10.0
Above 300 10.0 15.0
Write a C program using switch and if statements to complete the net amount to be paid
by a customer.
III. Loops
37. Write a program to read an integer, then add up the values of each of the individual
digits, and print out the sum.
38. Write a program to display all the factors of the given integer.
39. Write a program to check whether the given number has a perfect square or not.
40. Write a program to compute prime numbers between 1 and n using nested for loops.
41. Write a program to find GCD of two given numbers.
42. Write a program for square root of a number without using Built-in functions.
43. The total distance traveled by vehicle in ‘t’ seconds is given by distance = ut+1/2at 2
where ‘u’ and ‘a’ are the initial velocity and acceleration. Write C program to find the
distance traveled at regular intervals of time given the values of ‘u’ and ‘a’. The
program should provide the flexibility to the user to select his own time intervals and
repeat the calculations for different values of ‘u’ and ‘a’.
44. Write a program to determine and print the sum of the following harmonic series for a
given value of n:
1 + ½ + 1/3 + …………+1/n
45. Write a C program for the following
a. 1 + x2/2! + x2/4! + ------- upto ten termsb. x + x3/3! + x5/5! + ------- upto 7th digit accuracy
46. Write a C program for the series of 1/1! + 2/2! + 3/3! + 4/4! ……….
47. Write a C program to read a number and print the number in words
(e.g. 384 = Three Eight Four)
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
4
Lab Programs
48. Find out the given number is Armstrong or not.
49. Find out the given number is Strong number or not.
Hint: Sum of the factorials of digits = original number
50. Convert the Binary to Decimal Number
51. Two numbers are entered through the keyboard. Write a program to find the value of
one number raised to the power of another.
52. Write a program to print all the ASCII values and their equivalent characters using a
while loop. The ASCII values vary from 0 to 255.
53. Write a program to print out all Armstrong numbers between 1 and 500.
54. Write a C program to determine whether the given pairs (x,y) satisfying the equation
2x+2y = 200. Assume the x and y are in the range 0 to 200.
55. Write a program to output the following multiplication table:
5 x 1 = 55 x 2 = 105 x 3 = 155 x 4 = 20
.
.
.
.
56. Find the sum of n different numbers.
57. Find the n below even numbers sum and odd numbers sum
58. Find the even sum and odd sum for n different numbers
59. Convert the given number in single digit.
60. Find out the perfect number using for loop.
61. Write a program Cos series
62. Write a program Sin series.
63. Write a program to calculate sum of the squares.
64. To check the given number is prime or not.
65. Convert to Decimal to Binary.
66. Print the Fibonacci Series up to ‘n’ number.
67. Write a C program to list all the prime numbers below 100.
68. Program to display all the factors of the given number.
69. Program to display the numbers in the range 1 to 100, which are multiple of 3.
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
5
Lab Programs
70. Write a program to compute the sum of the series 1/12 – ½2 + 1/32 – ¼2 + …..1/n2
71. Two numbers are entered through the keyboard. Write a program to find the value of
one number raised to the power of another.
72. Write a program to print all Armstrong and strong numbers upto a given range.
73. Find the number of digits in given number.
74. Find the number of odd numbers & even numbers between 0 to given number.
75. To find the given number is unique number or not.
Hint: The reverse of the number * 9 = number
76. Write a program to find the difference between first & last digits of the number.
77. To find the position of the given number.
78. Find the LCM of two numbers.
79. To calculate number of 1’s and 0’s in binary digit number.
IV. Arrays
80. Sum of n numbers in an array.
81. Find the maximum and minimum of n numbers in an array.
82. Prints the array in reverse order.
83. To find the standard deviation.
84. Find the Transpose Matrix.
85. Find out the transpose matrix without using another array.
86. Find the diagonal sum of matrix.
87. Find the sum of two matrixes.
88. Find the second largest and second smallest in an array.
89. Program to insert a string into the main string.
90. Program to delete specified number of characters from the given position in a string.
91. Explain all string handling functions using switch case and loop.
92. Write a C program that outputs the given number at input into words. For example,
for the input 317, the program is to output THREE HUNDRED AND SEVENTEEN.
Assume input value is less than 1000.
93. Write a program to count the number of words, lines and characters in a text.
94. Write a program to count number of characters, no. of words, no. of special characters
in a given string.
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
6
Lab Programs
95. Write a program to count the number of vowels, special characters and consonants in
a given string.
96. Write a program to sort a list of strings into alphabetical order.
97. Write a program to delete duplicate values in an array.
98. Write a C program to obtain the product of two matrices A of size (3x3) and B of size
(3x2). The resultant matrix C is to be printed out along with A and B. Assume
suitable values for A & B.
99. Write a C program to extract a portion of a character string and print the extracted
string. Assume that m characters are extracted starting with the nth character.
100. Write a program test whether a given line of text is palindrome or not.
101. Write a program to find sum, average and maximum marks of 10 students.
102. To calculate number of even & odd numbers and sum of even and odd numbers in
an array. The array size is 20.
103. Write a program for swapping 2 strings.
104. Write a program to convert Roman numbers into number.
105. Write a program to find the Determinant of a matrix.
106. Write a program to print permutations.
Ex:- i/p:- 345 o/p: 3 4 5 3 5 4 4 3 5 4 5 3 5 3 4 5 4 3
107. Write a program to find the symmetry of the matrix.
108. Write a program to multiply two 3x3 matrices.
109. Write a program to find an input sub-string position in an input main string.
110. Write a program to read 5 numbers and display the number of Armstrong numbers
in that numbers.
111. Write a program to display the range of the input 5 numbers.
112. Write a program to read 5 numbers and display the number of prime numbers in
that numbers.
113. To display the following format
A B C D EF G H I JK L M N OP Q R S T U V W X Y
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
7
Lab Programs
114. To display the following format
A B C D1 2 3 4E F G H5 6 7 8
115. To display the following format
1 1 1 1 11 0 0 0 11 0 2 0 11 0 0 0 11 1 1 1 1
116. To display the following format
1 1 11 2 11 1 1
117. To display the following format2 1 11 2 11 1 2
118. To display the following format0 1 01 0 10 1 0
119. To display the following format1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 25
120. To display the following format1 6 11 16 212 7 12 17 223 8 13 18 234 9 14 19 245 10 15 20 25
V. Functions
121. Write a function to raise a number to a power when both are floating point numbers.
122. Write a function that will round a floating-point number to an indicated decimal
place. For example the number 17.457 would yield the value 17.46 when it is
rounded off to two decimal places.
123. Write a function prime that returns 1 if its argument is a prime number and returns
zero otherwise.
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
8
Lab Programs
124. Write a program to multiply two numbers without using ‘x’ operator using
functions.
125. Return a maximum number in two integers.
126. Develop all string functions using functions.
127. To calculate sum of n numbers using passing arguments through functions method.
128. To calculate NCR using passing arguments through functions method.
129. Find the sub-string position in main string using functions.
130. Write a program to find the given number is strong number or not using passing
arguments through functions.
131. Write a program to find the given number is Armstrong number or not using
passing arguments through functions.
132. Create a user-defined function for calculating the sum of digits in input number
using recursive method.
133. Write a program to convert decimal numbers to roman equivalent upto 10,000 using
passing arguments through functions method.
134. Write a program to print the number in reverse using recursion method.
135. Write a program to print fibonacci series in recursion method.
136. Write a program for computing area, volume and perimeter of rectangle using
function with looping.
137. Write a Program for Binary, Octal, Hexadecimal Conversions
138. Write a Program to print the ascii values of all characters in the entered string.
139. Write a Program to find & replace any desired character from the input text.
140. To print percentage chart by passing values into functions.
141. Write different functions for swapping for different data types.
142. Write a program add two numbers in recursive method.
143. Write a program to find the gcd of two numbers using the following Euclid’s
recursive algorithm.
gcd(n, m) if n > m
gcd(m, n) m if n = 0
gcd(n, m%n) otherwise
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
9
Lab Programs
VI. Pointers144. Write a program to compute the sum of all elements stored in an array using
pointers.
145. Write a C program using pointers to determine the length of a character string.
146. Write a C program develop all string functions using pointers.
147. Write a C program to find out the presence of a sub-string in a given string using
pointers.
148. To find the smallest in an array of ‘n’ elements using pointers.
149. To find the biggest number in two integers using pointers and functions.
VII. Structures and Unions
150. Write an interactive program to process complex numbers. It has to perform
addition, subtraction, multiplication, and division of complex numbers.
151. Write an interactive program, which processes date of birth using structures.
Enhance the same supporting processing of multiple students date of birth.
152. To develop a structure contains Roll number, name, marks [3], total, and average of
a student structure for multiple students and display result of each student.
153. Develop a structure of employee contains name, department and basic salary and
calculate da, hra of each employ.
154. To develop a book_bank structure contains title, author, pages, price for different
books.
VIII. Files
155. Appending the data into existing file.
156. Copy the contents in one file to another file.
157. Display a ‘C’ program at run time.
158. To display the number of words, upper letters, lower case letters, spaces and special
symbols in a file.
159. To store the student details in .txt file.
160. To print the details in an ascending order.
161. /* Menu driven program on files
CREATE A FILE CALLED MARKS.DAT WITH THE STRUCTURE STUDENTNUMBER, STUDENT NAME, MARKS IN PAPER1, MARKS IN PAPER2, ANDMARKS IN PAPER3. INPUT ANY RECORDS. CALCULATE THE TOTAL
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
10
Lab Programs
AND AVERAGE FOR EACH STUDENT.
IF AVERAGE IS >=60 THENDECLARE THE RESULT AS FIRST;COPY THAT STUDENT INFORMATION TO A FILE CALLED FIRST.DAT
WITH HIS NUMBER, NAME, TOTAL AND AVERAGE.
IF AVERAGE IS >=50 THEN DECLARE THE RESULT AS SECOND; COPY THAT STUDENT INFORMATION TO A FILE CALLED SECOND.DAT WITH AGAIN HIS NUMBER, NAME, TOTAL AND AVERAGE.
IF AVERAGE IS <50 THEN DECLARE THE RESULT AS FAIL; COPY THAT STUDENT INFORMATION TO A FILE CALLED FAIL.DAT WITH AGAIN HIS NUMBER, NAME, TOTAL AND AVERAGE.
WRITE A MENU DRIVEN PROGRAM WITH THE FOLLOWING OPTIONS:1:CREATION2:APPENDING3:PROCESSING4:FIRST_CLASS STUDENTS5:SECOND_CLASS STUDENTS6:FAILED STUDENTS7:EXIT
IF THE THIRD OPTION IS SELECTED, PRINT THE OUTPUT IN THEFOLLOWING FORMAT:----------------------------------------------------------
Millennium Software SolutionsVisakhapatnam
-----------------------------------------------------------SL STUDENT STUDENT TOTAL AVERAGE RESULTNO NUMBER NAME MARKS MARKS-----------------------------------------------------------
-----------------------------------------------------------*/
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
11
Lab Programs
Nested Loops
Write C programs for the following formats
162. 1 2 3 4 5 163. 1 2 3 4 5 164. 1 1 2 3 4 2 3 4 5 2 1
1 2 3 3 4 5 3 2 1 1 2 4 5 4 3 2 1
1 5 5 4 3 2 1
165. 1 166. 1 1 167. 1 2 3 4 5 5 4 3 2 1 1 2 1 2 2 1 1 2 3 4 4 3 2 1 1 2 3 1 2 3 3 2 1 1 2 3 3 2 1
1 2 3 4 1 2 3 4 4 3 2 1 1 2 2 11 2 3 4 5 1 2 3 4 5 5 4 3 2 1 1 1
168. 1 1 169. 1 170. 1 2 2 1 1 2 1 1 2 3 3 2 1 1 2 3 2 1 1 2 3 4 4 3 2 1 1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1 1 2 3 2 1 1 2 1 1
171.
MILLENNIUM SOFTWARE SOLUTIONS Visakhapatnam
12