0% found this document useful (0 votes)
49 views22 pages

C Assignment

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
49 views22 pages

C Assignment

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 22

ASSIGNMENT

Week 1(Day 1-6)


we a C program to enter twonumbers and find their sum.
2. Write a program to enter twe naumbers and perform all arithmetic operations.
3. Write enter lenth and breadth of a rectangle and find its perimeter.
a C program to
4. Write a Cprogram to enter len
enter
lenth and breadth ofa rectangle and find its area.
5. Write a C program to enter radus of a cdircle and find its diameter, circumference and area.
6. Write a C program to enter lensth in centimeter and convert it into meter and kilometer.

7. Write a C program to enter temperature in Celsius and convert it into Fahrenheit.


W r i t e a C program to enter temperarure in Fahrenheit and convert to Celsius
.Write a C program to print your name, date of birth and mobile number.

txpectud Output:
Name Armit Jain
DOB :July 14, 1975
Mobile 91 9999999999

10. V.ite aC prog 1m to print block F usig hash (), where the Fn height of six characters and width of
five and four characters

Expected Output

11. Write aC program to print a big'C


Expectet Output:

12. Wrte a C program to pit the tollowing characters in a reverse way.


Test O aracters: *', "M, 1
pect 2d Otput:
The rverse of XML is LMY

13. Write a i program to tonpute the perimeter and area of a rectang vwith a he-ght of 7 inches. and widtn
of S in hes
Expecd Output:
Perim tr d the rectangle* 4 inces
Area h e rectangle r *5 S0are i n h e s

4.Write aC program to u ute the perimeter and ares of a cirete with a radius of 6 inches.
Expe ted Output:

UNIVERSAL INFORMATIc
www.Uversalinformatics.comE-mail:info@universalintornatics.com
Perimeter of the Circle CASSIGNMENT
Area of the 37.680000
Circle 113.040001
inches =
square inches
15. Write aC
program to display multiple variables.
Sample
a*
Variables
C, X+C,dx +
x, (int) dx) +
ax, a+x, S+ b, ax +b,
Declaration: s+ C, ax+C, ax+ Ux
int a =
125, b =
12345,;
long ax 1234567890;=

short s= 4043;
float x 2.13459;
double dx =
1.1415927;
char c =
'WN';
unsigned long ux 2541567890; =

16. Write a C
program to convert specified days into years, weeks and days.
Note:
lgnore leap year.
Test Data
Number of days 1329
Expected Output:
Years:3
Weeks: 33
Days:3

17. WriteaC program that


accepts two integers from the user and calculate the
Test Data: sum of the two
integers.
Input the first integer: 25
Input the second integer: 38
Expected Output:
Sum of the above two
integers =
63

18. Write a C program that accepts two


Test Data
integers from the user and calculate the product of the two
integers.
nput the first integer: 25
Input the second integer: 15
Expected Output:
Product of the above two integers = 375

Week 2(Day 7-12)


19. Write a C program to find
maximum between two
20. Write aC program to find maximum
between three numbers.,
numbers.
21. Write a C
program to check whether a number is negative,
22. Write a C
positive or zer.
program to check whether a number is divisible by 5 and
23. Write a Cprogram to check whether a
11 or not.
number is even or odd.
24. Write aCprogram to check
25. Write
is whether a year leap year or :ot.
aCprogram to check whether a character is alphabet or not.
26. Write a Cprogram to input any alphabet and check whether it is vowel or consenant.
27. Write aCprogram to input any character and check whether it is alphabet, digit or special chardcter.
28. Write a
Cprogram to check whether a character is
uppercase or lowercase alphabet.
29. Write au program to input week number and print week day.

UNIVERSAL INFORMATICS
www universalinformatics.comE-mail:info@universalinformatics.com
30. Write aC CASSIGNMENT
Write aC program
to
input month number and
31)
32. Write aC program to
count total number of print number of days In
that month.
program to notes in given
33.Write aC program to input angles a triangle and check amount.
of
triangle and checkwhether
34. Write
aC input all sides of a trlangle is valid or not.
35. Write program to check whether whether
aC the triangle Is valid or not.
36. Write program to find all roots of a triangle ls equilateral,
aC
program to calculate quadratic isosceles or scalene
37. Write
aC profit or loss. equatlon. triangle.
Caiculate program to input
marks of five
Percentagepercentage
> 90%:
and grade
according to
Grode A
subjects Physics, Chemistry,
Biology,
follaowing: Mathematics
Percentage >=
80% : Grade B
and
Computer.
Percentage >=
70% : GradeC
Percentage >=
60%:Grade D
tercentage >=
40% :
Grade E
fercentage <
40% :Grade F
J8. Write a C
progran to
tollowing
Basic Salary <=
input basic salary of an
employee and calculate its Gross
Basic Salary 10000 HRA salary according to
<=
20000 HRA
=
20%, DA =30%
Basic =
25%, DA
Salary> 20000: HRA
=
90%
=30%, DA 95% =

39. Write aC
program to
ondition: input electricity unit
For first 50
units ks.
charges and calculate total
For next
100 units Rs.0.50/unit electricity bill according to the
For next 100 0.75/unit given
units Rs.
For unit
above 250 Rs. 1.20/unit
An additional 1.50/unit
surcharge of 20% is added to the
0.)write aC program that bill
(Hoating points' values) accepts two item's weight
and
Test Data: calculate the average (floating points' values
Weight 1tem1: 15 value of the ) and number
items. of
purchase
No. of item1:5
Weight Item2: 25
No. of item2: 4
Expected Output
Average Value 19.444444
43.Write aC program that
received hour. Print theaccepts
employee'senployee's
per an
Test Data ID, total
ID and worked hours of
laput the salary (with two decimal places)month
a
and the
Input the Employees ID{Max. 10 chars): 0342 of a amount he
particular
working 15000
Salary amount/hr:hrs: 8 month.
Expected Output:
Einployees ID =u342
Salary US=

120000.00
42) Write aC
Test Data: program that accepts
three
hput the first integer: integers and find the
25 naximum of three.

UNIVERSAL INFORMAT!C
www.universalinformatics.com,E-mail:info@universatinfar1natics.co
CASSIGNMENT
nput the second integer: 35
nput the third integer: 15
xpected Output:
Maximum value of three integers: 35

Write a C program to calculate a blke's average consumption from the glven total distance (integer value)
raveled fin km) and spent fuel (n liters, float number-2 decimal polnt).
Test Data:
Input total distance in km: 350
Ioput total fuel spent in liters:5
Expected Outpiut:
Average consumption (kn/t) 70.000

A Write C program to calculate the distance between the two points.


Test Data
Input x1: 25
tnput y1: 15
Input x2: 35
Input y2: 10
Expected Output:
Distance between the said points: 11.1803

4. Wnte a C program to read an amount (integer value) and break the amount into smallest possible number
of bank notes.
Test Data
Input the amount: 375
Expected Output:
here are:

3 Notels) of 100.00
1 Note(s) of 50.00
I Note(s) of 20.00
O Noteis) of 10.00
1 Note(s) of 5.00
O Note(s) of 2.00
O Notels) of
1.00
46. Write a Cprogram to convert a given inteyer(in seconds) to hours, minutes and seconds.
Test Data:
Input seconds: 25300
Expected Output:
There are:
H:M:5-7:1:40
A7.Write aCprogram to converta given integer (in days) to years, inonths and days, assumes that all months
have 30 days and all years have 365 ilays.
Test Data :

Input no. of days: 2535


Expected Output:
Yitar(s)
11 Months)
15Dayls)

UNIVERSAL INFORMATIcS
www.universalinlormatics.comE-niall:info@universatin.formatics.rom
CASSIGNMENT
8)Wrnte a C
program that
gis 8reater thanr and s isaccepts
4
if integers p, 9,r, s from the user
"Correct values", otherwise greater than p and if the wherer ands are
sum ofr and s is positiveand p is even.
print "Wrong values. greater than the sum of p and
q print
Test Pthe m
Inpur' secondfltitan
integer: 35 to
input the third
integer: 15
Input the fourth
integer: 46
Expected Output:
Wrong values

9. Write a C
program to print the roots of
a
message if it is not Bhaskara's formula from the
possible to find the roots given three ffoating numbers.
Test Data: Display
Input the first
number(a): 25
Input the second number(b): 35
input the third number(c): 12
Erfcted Output:
HO Jtl= -0.60000
Root2 = -o.80000

50. Write a C
program that reads an integer and
message if the number is negative and check the specified
range where it belongs. Print an error
Test Data: greater
than 80.
Input an integer: 15
Expected Output:
Range (0, 20

Write aC program that read 5 numbers and


Test Data: sum of all odd values between them.
Input the first number: 11
nput the second number: 17
input the third number: 13
Input the fourth number: 12
Input the fifth number: 5
Expected Output:
Sum of all odd values:
46

$2 Write aC program that


reads three floating values
Also calculate the and check if it is
Test Data:
perimeter of the
triangle if the said values are valid. possible to make a triangle with
then.
Input the first 5 integer:
Input the second integer: 15
Input the third
integer: 10
Expected Output:
Numbers in sorted oruer: 5 10 15

Week 3(Day 13-16)


53. Write a C
54. Write
program to
print day of week name
a C program
print total number of using switch case.
55. Write a C days in a month
prograni to check whether an using switc:
alphabet is vowel or consonantcase.
sing switch case.
UNIVERSAL INFORMATICS
www.universalinfor1natics.comE-mail:info@universalinformatics.com
CASSIGNMENT
S6. Wnte aprogram to find maximum between two numbers using switch
57. Write a Cprogram to
check whether a number is even or odd using switchcase.
58.Write ac program to check whether a case.
59, Write ac program to find roots of a number positive, negative
is or zero using switch case. .

60.Write ac program to quadratic equation using switch case.


create Simple Calculator using switch case.
61. Write ac program to print all natural numbers from 1to n. using while
62.Write ac program to print all loop
natural numbers in reverse (fromn to 1). using while
63. Write a C program to
-

loop
print all alphabets from a to z. using while loop
-

64. Write acprogram to print all even numbers between


65. Write a c program to 1 to 100. using while loop
66. Write aC program to
print all odd number between 1 to 100.
find sum of all natural numbers
67. Write aC between 1 to n.
program to find sum of all even numbers
68. Write aC between 1 to n.
program to find sum of all odd numbers
69. Write a C program to between 1 to n.
print
70, Write aC program to coantmultiplication
table of any numbere
nunler of digits in a
11, Write aC program to find first and last digit of number.
2. Write aCprogram to find sum of first
anumber.
3Write C program to swap first and
a and last digit of a number
74, Write aC program to calculate last digits of number. a

Write aC program to calcufate sum of digits of a number.


16.Write program to entera
aC product of digíts of number. a
number and
print its reversey
7. Write aC program to check whether a number
is palindrome or not.
78, Write aC program to find
frequency of each digit in a given integer.
9Write a C
80. Write aC
program to enter number and print it in words.
a

program to print all ASCIl


character with their values.
81. Write aC
program
find power of a number using for
to
82. Write a C loop.
program to find all factors of a number.
83. Write aC program to
calculate factorial of a number.
84. Write aC
program to find HCF (GCD) of
85. Write aC
program to find LCM
two numbers.
86. Write of two numbers.
aCprogram to chec whether a number is Prime number or not.
87 Write aC program to print all Prime numbers between 1 to n. Write a C program to
upto n rows. print Pascal triangle
88. Write a
programC to find sum of all prime numbers between 1 to n.
89. Write aC program to find all prime factors of a number.
90. Write a C program to check
whether a number is
91. Write aC program to print all Armstrong numbersArmstrong number or not.
between 1 to
92. Write aC program to check n.

93. Write aC program to


whether
a number is
Perfect number or not.
print all Perfect numbers between 1 ton.
94. Write aC program to check
whether a number is
95. Write aC program te Strong number or not.
allprint Strong numbers between 1 to n.
96. Write aC program to print Fibonacci series
97. Write
aCprogram to up to n terms.
print Pascal triangle upto n rows.
***

***

*****

****

*****

Square Star Pattern


*****

UNIVERSAL INFORMATICS
www.universalinformatics.comE-mail:info@universalyrmatics rr
CASSIGNMENT

..
Hollow Square Star PatternWeek 5

*****

Hollow Square Star Pattern with Diagonal


***
**

****

Rhombus Star Pattern


+****

****

Hollow Rhombus Star Pattern


**

*****

*****

****

*****

Mirrored Rhombus Star Pattern

Hollow Mirrored Rhombus Star Pattern

Right Triangle Star Pattern

Hollow Right Triangle Star Pattern

UNIVERSAL iNFORMATICS
www.universalinforniatics.com.E-mait:info@universalinforn
CASSIGNMENT
**

Mirrored Right irangle Star Pattern

Hollow Mirrored Right Triangle Star Pattern


98. Write a C that reads three floating values and check if it is
program possible to make a triangle with them.
Also calculate the perimeter of the
triangleif the said values are valid.
Test Data:
Input the first number: 25
Input the second number: 15
Input the third number: 35
Expected Output:
Perimeter = 75.0

99. Write a C program that reads two


integers and checks if they are
multiplied or not.
Test Data:
Input the first number: 5
Input the second number: 15
Expected Output:
Multiplied!
100. Write aC program that reads an
integer between 1 and 12 and print the month of the year in English.
Test Data
Input a number between 1 to 12 to get the month name:8
Expected Output:
August

101. Write aC program that prints all even numbers between 1 and 50
est Data : (inclusive).
Even numbers between 1 to 50
(inclusive):
Expected Output:
2468 10 12 14 16 18 20 22 24 26 28 30 32 34
36 38 40 42 44 46 48 50
102. Write 3C program that read 5 nuirbers
and
Numbers. counts the number of positive numbers and negative
Test Data
Input the first number:5
lnput the second number: -4
Input the third number: 10
Input the fourth number: 15
nput the fifth number: 1
Expected Output:
Number of positive numbers: 3
umber of negative numbers: 2

UNIVERSAL INFORMATIcs
www.universalinformatics.com.E-mail:info@universalinforinatics.co
CASSIGNMENT
103. Write ac program that read 5 numbers and counts the number of
average of all positive values. positive numbers and print the
Test Data:
Input the first number: 5
Input the second number: 8
Input the third number: 10
Input the fourth number:-5
Input the fifth number: 25
Expected Output:
Number of positive numbers: 4
Average value of the said positive numbers: 12.00
104. Write aC program that read S
numbers and sum of all odd values between
Test Data: them.
Input the first number: 5
Input the second number: 7
Input the third number: 9
Input the fourth number: 10
Input the fifth number: 13
Expected Output:
Sum of all odd values: 34

105. Write aC program to find and print the square of each one of
the even values from
Test Data: 1 to a
specified value.
List of square of each one of the even values from 1 to a 4:
Expected Output:
242- 4
42 16

106. Write a C
program to check a given integer is positive even, negative
Print even if the number is 0. even, positive odd or negative odd.
Test Data:
Input an integer: 13
Expected Output:
Positive Odd

107. Write aC
program to print all numbers between 1 to 100 which
remainder will be 3. divided by a specified number
and the
Test Data:
Input an integer: 25
EXpected Output:
28
53
78

108. Write C
a
progran that accepts some integers from the user and find the
position. highest value and the input
Test Data:
Input 5 integers:

UNIVERSAL INFORMATICS
www.universalinformatics.com.E-mail:info@universalinforn.atics.co
C ASSIGNMENT

15
23
a5
Expected Output:
Highest value: 45
Position: 5

109. Write aCprogram to print the numbers from the lowest to the highest (inclusive) and the sum of
consecutive integers from a given pair of numbers.
Test Data:
Input a pair of numbers (for example 10,2):
Input first number of the pair: 10
Input second number of the pair: 2
Expected Output:
List of odd numbers: 3
5

Sum=24

110. Write a C program to check if two numbers in a pair is in ascending order or descending order.
Test Data
input a pair of numbers (for example 10,2: 2,10):
Input first number of the pair: 10
Expected Output
Input second number of the pair: 2
The pair is in descending order!

Weet 4(Day 17-24)


111. Write a C program to find cube of any number using function.
112Write a C program to find diameter, circumference and area of circle using functions.
113. Write a C program :a find maximum and minimum between two numbers using functions.
114. Write a C program to chetk whether a number is even or odd using functions.
115. Write
a C program to check whetier a number is
prime,
Armstrong or perfect nunuber
116 Write C program to find all prime numbers between givea interval usirng functions.
using functions.
117. WriteC program to print all strong numbe:s between given interval using functions.
1i8Write a C program to print all Armstrong nurmbers between given interyal using functions.
119. Write aC program to print all perfect numbers between given interval using functions.
120. Write aC program to find power of any number using recursion.
171. Write a C program to print all nara numbers between 1 to n using recursion.
122. 14rite a C program to print all even or oad numbers in given range using recursion.
122. Write a C program to find sum of all natural rumbers hetween 1 to n using recursion.
124. Write a C program to find sum of ali even or odd numbers in given range using recursior.
125. Write a C program to find reverse of any nuinber using recursion.
126. Write a C program to check whether a number is palindrome or no: using recursica.
127. Write a Cprogram te find sum of digits of a given number usirg recursion.
128. Write a C program te find factorial of any nunber using recursion.
129. Write aC progranm ts generate nth Fibonacci term using recursion.
130. Write aC progran. to find GCD {HC) of two nembers usiag recursion.

UNIVERSAL INFCRMA:ICS
www.universalinfor1natics.com,E-maii:inf-@uiversa.clormJiics.201
CASSIGNMENT
a C program
131. Write find LCM of two numbers using recursion.
to

132. Write acprogram to read and


print elements of array. using recursion.
133. Write ac program to
print all negative elements in an array.
134. Write ac program to find sum of all array elements. using recursion.

135. Write aprogrdm to find maximum and minimum element in an array. using recursion.-
a C program to find second
136. Write largest element in an array.
137. Write ac program to count total number of evert and odd elements in an array.

138. Write aCprogram to count total number of negative elements in an array.


139. Write a Cprogram to copy all elements from an array to another array.
140. Write a c program to insert an element in an array.
141. Write ac program to delete an element from an array at specified position.

142. Write aC program to count frequency of each element in an array.


143. Write a C program to print all unique elements in the array.

144. Write a C program to count total number of duplicate elements in an array.


145. Write a C program to delete all duplicate elements from an array.
146. Write a C program to merge two array to third array.
147. Write a C program to find reverse of an array.
148. Write a C program to put even and odd elements of array in two separate array.
149. Write a C program to search an element in an array.
150. Wrice a C program to sort array elements in ascending or descending order.
151. Write a C program to sort even and odd elements of array separately.
152 Write a C program to lett rotate an array.
153 Write a C program to right rotate an array.

154.Write a Cprogram to add two matrices.


155 Write a C program to subtract two matrices.
156. WriteaC program to perform Scalar matrix multiplicatior
157. WriteaC prograin to multiply two matrices.
156. Writea Cprogran whether two matrices are equal or not.
to check

C prograrn to find sum of main diagonal


elements of a matrix.
159. Write a
elements ofa matrix.
160. Wiite a C program to find sum of minor diagonal
matrix.
161. Writea C program to find sum of each row and column of a

of a matrix.
1¬2. Write a C program to interchange diagonals
matrix.
C program to find upper triangular
163Write a
triangular matrix.
to find lower
164,Write a C program
165. Write a C program to find sum of upper trianguler matrix.
matrix.
166. Write a C program to find sum of lower triangular
find iranspose of a matrix.
167. Write a C program to
determinant of a matrix.,
168. Write a C program to find
matrix.
169. Write a C program to check ldentity
check Sparse matrix.
170. Write a C program to
C program to check
Sy1nmetric matrix
171. Write a
and use pointers.
tu create, initialize
172. Write aC program
to add two numbers using pointers.
Write aC program numbers using pointers.
a C progra1
tu "wap two
74. Write
to input and print array elements using pointer.
1%. wtite a Cprogram
another using pointers.
176. Write aCprogram to copy array to one

two arr2ys using pointers.


177. Write a Cprogram tos vap
178. Writea C progran to
r v e r s e an array using pointers.
to scarch an
element in array using poirters.
79. Write a C program
ac:esS two dinensional array using pointers.
80. Write a C program to
81. Write a C program to
adu' t o Imatrix using pointers.

UNIVERSAL :iFORVANTICS
www.universalinformatics.com ë-mail:infuuniversali:ormatc.20*
CASSIGNMENT
a C program
Write to
multiply two matrix using pointers.
183, Write aC program to find
length of string using pointers.
184. Write a Cprogram to copy one string to another using pointers.
185. Write ac program to concatenate two strings using
C program
pointers.
126. Write a to
compare two strings using pointers.
C program
187. Write a to find reverse of a string using pointers.
188.Write ac program to sort array using pointers.
189. Write a C program to return multiple value from function using pointers.

190.Wrte aprgram to read a password until it is correct. For wrong password print "Incorrect password"
and for correct password print "Correct password" and quit the program. The correct password is 1234.
Test Data
Input the
password: 1234
Expected Output
Correct password

191. Write a Cprogram to read the coordinates(x, y) (in Cartesian system) and find the quadrant to which it
belongs (Quadrant -1, Quadrant -I1, Quadrant-l1, Quadrant -V).
Note: A Cartesian coordinate system is a coordinate system that specifies each point uniquely in a plane by a
pair of numerical coordinates.
These are often numbered from 1st to 4th and denoted by Roman numerals: I (where the signs of the (%,y)
coordinates are I(+,+), li (-+), lII (--), and IV (+-)
TestData:
Input the Coordinate(x,v):
X: 25

y:15
Expected Output:
Quadrant-l(++)|
192. Write a program that reads two numbers and divide the first number by second number. If the division
not possible print "Division not possible".

Test Dala:
Input two numbers:
X: 25

Expected Output: 5.0

193. Write aC program to calculate the sum of all number iot divisible by 17 between two given integer

numbers.

TestData: 99
Input the first integer: 50 Input the second integer:
Expected Output:
Sum: 3521

it bý 7 and the remainder is equal to 2 or 3 between


194. Write a Cprogram to find all numbers which dividing
Two giver i e g numbers.

Test Data:
nput the first integer: 25
liput the second integen: 45

Expected Output:
S0

UNIVERSAL INFORMATICS
www.universalinformatics.com.E-mail:into@universatinformstics.co
CASSIGNMENT

38
14
lines
line, starting from 1 and print lines. Accept number of
195. Write ac program to print 3
(n, integer) from the user.
numbers in a
n

Test Data

number of lines: 5
Input
Expected Output:

123
456
789
10 11 12
13 14 15

1 and print n lines.


program to print number, it's square and cube in a line, starting from
196.Write aC a

Accept number of lines (n, integer) from the user.

Test Data
number of lines: 5
Input
Expected Output:
111
2 48
3927
4 1664
5 25 125
p number of lines in a sequence of 1 to b in a

197. Write a Cprogram that reads two integers p and q, print


line.
Test Data:

inputnumiber of lines:5
Number of characters in a line: 6

Expected Output:
123456
789i0 11 12
13 14 15 16 i7 18
19 20 21 22 23 24
25 26 27 28 29 30

of students. Input 0 (excluding to


calcuiaic the average marks of mathematics
some
198. Write a Cprogram te

negative value to terminate the input process.


Calculate the average) or

Test Data 10
Input Mathematics marks (0 to terminate):

20

Eypected Output:
Mathematics: 17.50
HVerage marks in
199. Write a C program to calculate the value of S where S = 1 + 1/2+ i/3 .. 1/50.

txpected Output

UNIVERSAL INFORMATIeS
www.universalinformatics.ccn,E-:nail:infouniversen 'ormatics.ru
CASSIGNMENT
S: 4.50
Value of

write a Cprogram to calculate the value of S where S = 1+3/2+ 5/4+7/8.


Expected Output:

series: 4.62
Value of

201. Write ac program that reads an integer and find all its divisor.

Test Data:
integer: 45
Input an
Expected Output:

All the divisor of 45 are:

202. Write a C program to read and print the elements of an array of length 7, before print replace every
negative number, zero with 100.

Test Data:
Input the 5 members of the array:

Expected Output:
Array vaiues are:
n0= 25
n[1)= 45
n2] 35
n[3 0
n[4] 15

203. Write a C program to reaú and print the elements of an array of length 7, before print, put the triple of
the previous position starting from the second position of the array.
For example, if the first number is 2, the array numbers must be 2, 6, 18, 54 and 162

Test Data:

Inputthe first number of iharray: 5


Expected Output:
n[C =5
n1= 15
45
n3 135
n4)= 405

204. Write a C program to read an array f length 5 and print the position and value of the array elements of
value less than 5.
Test Data:

UNIVERSAL INFORMATICS
www.universalinformatics.ccm,E-mail:info@univer: informe ics. u
C ASSIGNMENT

Input the
5 members of the
array (15
15
25
4
35
40
Expected Output:

A[2]=4.0
to read an array of length 6, change the first element by
the last, the second element
205. Write acprogram
of the modified array.
and the third element by the fourth. Print the elements
by the fifth
Test Data:
5 members of the array:
Input the
15
20
25
30
35

Expected Output:
array_n[0] -35
arrayn[1= 30

array_n[2]= 25
=
20
array n[3]
array n[4)= 15

Week 5(Day 25-31)


206. Write a C program to find length of a string.
207. Writea C program to copy
one string to another string
208. WriteaCprogram to concatenate two strings.
two strings.
209. Writea C program to compare
210. WriteaC program to
convert lowercase string to uppercase.

string to lowercase.
convert uppercase
211. Writea C program to
ofeach character of string-
a

2. Write aC program tortogglécasenumber digits or special character


in a string.
Write Cprogram to find total of alphabets,
%. a
and c o n s o n a n t s in a string.
number
program to
cou:nt tota! of vowels
X4. iVrite aC total nuuher of words in a string.
Cprogram to count
Write a of a string.
find reverse
W r i t e aC program to not.
string is palindrome or
217. Write aC program tu rheck whether a

order of words in a given string.


218. Write a C program to reverse

find first occurrence of a character in a given string.


219. Write a C program to
find last occurrence of a character in a given tring.
220. Write a C program to
to search all occurrences of a chaiacter in given string.
221. WriteaC program
o c c u r r e n c e s of a given string.
character in
222.
Writ C program tc cour:t
a
character in a string.
223. Write a C program to find hii;nest frequency
lowest frequency character in string.
L24. Write a C program to find
of each character in a strir?.
225, Write a C program to count frequency
of a character from siring.
remove first o c c u r r e n c e

2. Write aC program to
occurrence oí a character from string.
227. Mrite a C program to r e m o v e iast
occurrences ofa character
from string.
.8. Write a C program to remave all

UNIVERSAL INFORMATICS
www.universalinformatics.com,E-mail:infro@urive saliniornatS.co
CASSIGNMENT
229. Write at program to remove all repeated characters from a given string
230. Write a program to replace first occurrence of a character with another ina string.

231. Write aprogrdm to replace last occurrence of a character with another in a string
232. Write aprogram to replace all occurrences of a character with another in a string.
233. Write aC program to find first occurrence of a word in a given string
234. Write acprogram to
find last occurrence of a word in a given
Write a program to search all occurrences of a word in given
string
235. string
236. Write ac
program to count occurrences of a word in a
given string
237. Write aCprogram to remove
first occurrence of a word from string
238. Write a to remove last occurrence of a word in
Cprogram given
239. Write ac program to remove all occurrence of a word in given string.
string
240. Write a C program to trim leading white space characters from given string
.241. Write a c program to trim trailing white space characters from given string.
242. Write acprogram to trim both leading and trailing white space characters from given string
243. Write a C program to remove all extra blank spaces from given string.
244. Write a C program to read an array of length 6 and find the smallest element and its position.
Test Data:
Input the length of the array: 5 Input the array elements:
25
35
20
14
45
Expected Output:
Smallest Value: 14
Position of the element: 3

interest.
245. Write a C program that accepts principle, rate of interest, time and compute the simple
Test Data:
p= 10000,r= 10%, t =
12 year
input Data:
Expected Output:
simple interest:
Input principle, Rate of interest & time to find
Simpleinterest 12000

distance in centimeters and prints the corresponding value in inches.


246. Write aCprogram that accepts
a

lest Data:
Input Data: 500cms
in cm:
Input the distance
Distance of 500.00 cms is = 196.85 inches

using third variable.


two iumhers without
program that swaps
247. Wsite aC
Input value for x & y
value of x & y:57
Before swapping the
& y: 75
swapping the value of
x
After

data by two bits to ihe left.


248. Write aC prograrn to shift given

input value:2
Read the integer from keyboard-
Integer value = 2

The left shifted data is = 16

UNIVERSAL INFORMATICS
www.universalinformatics.comE-inailinf.@universalinfor.n.ics.con
CASSIGNMENT

a C program to reverse and print given number.


249, Write a
Input a number:

234
number =

The original
The reverse of the said number =432

numbers from the keyboard and print out the difference of the
250. Write a C
program that accepts 4 real
mininmum values of these four numbers.
maximum and
four numbers: 1.54 1.236 1.3625 1.002
Input
Difference is 0.5380

251. Write a C program to


display sum of series 1+1/2+ 1/3+ ..+ 1/n.
Input any number: 1+ 1/0
Sum 1/0

a C program to create enumerated data type for 7 days and display their values in integer
252. Write
constants.

Sun = 0
Mon = 1

Tue2
Wed =3
Thu 4
Fri - 5
Sat = 6

real number and prints out the corresponding value of sin(1/x) using
253. Writea Cprogram that accepts a x

4-decimal places.
Input value of x: .6235
Value of sin(1/x) is 0.9995

out the of the digits of this


254. Write a Cprogram that accepts a positive integer less than 500 and prints sum

number.
Input a positive number less than 500:
Sum of the digits of 347 is 14

less than 100 from the user and prints out the sum 14
255. Writea C program that accepts a positive integer n

+24+44+ 74+ 114+**m4, where m is less than or equal ton. Print appropriate message.

Input a positive number less than 100: 68


Sum of the series is 37361622
256. Write a C program that accepts integers from the user until a zero ora negative number, display the
number of positive values, the minimum value, the maximum value and the average of all numbers.

Input a positive integer


input rext positive integer: 15
Ingut next positive integer: 25
Input next positive integer: 37
Input next positive integer: 43
Number of positive values entered is 4
iaximum vaiue entered is 43

Minimum value entered is 15


Average value is 30.0000

UNIVERSAL INFORMATICS
www.universalinformatics.comE-mail:info@universaliaformatics.com
257. Write aprogram that prints out the
CASSIGNMENT
prime numbers between
(1
1 and 200. The output should be such that
each row contains a
maximum of 20 prime numbers.
Expected output:
The prime numbers between 1 and 199 are:
235711 13 17 19 23 29
31 37 4143 4753 59 61 67 71
73 79 83 8997 101 103 107 109 113
127 131 137 139 149 151 157 163 167 173
179 181 191 193 197

258. Write ac program that generates 50 random numbers between -0.5 and 0.5 and writes them in a file
rand.dat. 1he tirst ine of ran.dat contains the number of data and the next 50 lines contains the 50 random
numbers.
50
-0.4215
0.2620
0.3065
-0.0485
.0.3980

0.1750
0.478
-0.2915
0.0715
0.3565

259. Write aC program to evaluate the equation y=xn when n is a non-negative integer.
Input the values of x and n: 256
x-256.000000; n=0;
x to power n=1.000000

260. Write aC program to print the powers of 2 table for the power 0 to 10, both positive and negative.
====***======**--==========

n2 to power n 2 to power -n
========-== **

01 1.000000000000
120.500000000000
240.250000000000
380.125000000000
4 16 0.062500000000
S 32 0.031250000000
6 64 0.015625000000D
7 128 0.C07812500000
3 256 0.003906250000
9512 0.001953125000
10 1024 0.000976562500
=zz======

Weak 6(Day 32-37)


261. Store Information of 10 Students Using Structure
262. CProgram to Store Information ofStudents Using S*ruciure

UNIVERSAL INFORMAT'CS
www.universalinformatics.com.E-mail:info@unive:valiniormatics.com
CASSIGNMENT
263. StoreIntormation(name, Id and salary) of a Employee Using Structure
264. C Program to store Information Using Structures with Dynamically Memory Allocation

265. Store lntormation(name, roll and marks) of a Student Using Structure


266. Write ac program to create a file and write contents, save and close the file.
267. Writeacprogram to read file contents and display on console.
268. Write ac program to read numbers from a file and write even, odd and prime numbers to separate file.
269. WriteaCprogram to append content to a file.
270. Write a C program to compare two files.
271. Writeacprogram to copy contents from one file to another file.
272. Write aCprogram to merge two file to third file.
273. Write ac program to count characters, words and lines in a text file.
274. Write aC program to remove a word from text file.
275. WriteaCprogram to remove specific line from a text file.
276. Write aCprogram to remove empty lines from a text file.
277. Write a C program to find occurrence of a word ina text file.
278. Write a C program to count occurrences of a word in a text file.
279. Write a C program to count occurrences of all words in a text file.
280. Write a C program to find and replace a word in a text file.
281. Write a Cprogram to replace specific line in a text file.
282. Write a C program to print source code of same program.
283.Write aC program to convert uppercase to lowercase character and vice versa in a text file
284. Write a C program to find properties of a file using stat() function.
285. WriteaCprogram to check if a file or directory exists.
286. Write a C program to rename a file using rename() function.
287. Write a C program to list all files and sub-directories recursively.
288. Write a Cprogram to print a binomial coefficient table.
Mx 0123 4 56789 10
- -

****

01
11
2121
31331
414641
515 10 105 1
616 15 20 15 61
71721 35 35 21 71
81828 56 70 56 28 8 1
91936 84 126 126 84 3691
10 1 1045 120 2:0 252 210 120 45 101

289. Write a C program to print the alphabet set in decimal and character form.
[65-A 66-8] [67-C} 168-D] [69-E] [70-F] {71-G] [72-H] [73-1] [74-J] [75-K] {76-L] {77-M] [78-N] [79-0] [80-P] [81-Q
82-R} {33-S] (84-T] 185-U] [86-V] [87-W] [88-xj 189-V
[90-2] {97-a] [98-b] [99-c] [100-d] [101-e] [102-1] |103-g) {204-h} [105-i] |106;} [107-k] [108-1) {109-m] [110-n]
111-cl[112-p] [113-q] [114-r] [115-s] [116-t] [117-u] {118-v]
[119-1120-x] |121-vl [122-z]
0 . Write a C program to copy a given string into another and count the niumber of characters copied.
Inpst a string
Origitai tring: w3resource
Number of cnaracters = 10

UNIVERSAL INFORMATICS
www.universalinformatics.comE-mail:info@univessalin.ormatics.com
CASSIGNMENT
291. Write aCprogram to
remove any
2
Input a value (negative): negative sign in front of a number.
Original value = -253

Absolute value = 253

292. Write a c
programming that reads in two
second integer. integers and check whether the first
integer is
Sample Input: 9 3
a
multiple of the

Sample Output:
Input the first integer Input the second
9 is a multiple of 3. integer:

293. Write aC
programming to display the integer
Sample Output: equivalents of letters (a-z, A-2).
List of integer equivalents of letters (a-z, A-Z).
*****

97 98 99 100 101 102


103 104 105 106 107 108
109 110 111 112 113 114
115 116 117 118 119 120
121 122 32 65 66 67
68 69 70 71 72 73
74 75 76 77 78 79
80 8182 83 84 85
86 87 88 89 90

294. Write C
a
programming that accepts one seven-digit number
digits, and prints the digits separated from and separates the number into its individual
Sampie input: 2345678 one another by two spaces each.
Input a
seven digit
Output:2 3 4 5678number
295. Write aC
programming to calculate and
display them in a table of values. prints
uses tabs to the squares and
cubes of the numbers from 0 to 20
Sample Output: and
Number Square Cube

000 **
111
48
3927

18 2245832
19 361 6s59
20 400 8000

L9t.
Write aC
ne
simple interest for orogramming that accepts principal amouni, rate of
intëres= principal
the loan, using the interest and days 'or
"

rate days / 365. following formula. a loan and calculate


Sample Input:

UNIVERSAL INFORMATICS
www.universalinformatics.com,E-mail:info@universanforma'ics.com
CASSIGNMENT
10000
1
365

Sample Output:
Input loan amount (0 to quit): Input interest rate: Input term of the loan in days: The interest amount is

S1000.00
Input loan principaamt (0 to quit):

297. Write a Cprogramming to demonstrates the difference between predecrementing and postdecrementing
using the decrement operator -
Sample Output:

Predecrementing
x = 10
= 10
x = 9

C programming using looping produce the following table of values.


298. Write a to

Sample Output:
x+2 x+4 xt6
x
* *

6 8 10
7 9 11 13
10 12 14 16
13 15 17 19

(side sizes between 1 and 10) of a square and prints square


299. Writea C programming that reads the side
using hash(#) character.
Sampie Input: 10
Sample Output:
Input the size of the square:

# ##### # ###
###### # ## #

##########
# ####### ##
###### # # ##

##########
###t#### *#
######## ##
##########
#####H ####
between 1 and 10 ) of a square and prints a hollow
300. Write aC programming that reads the side (side sizes
square using hash (#) character.

Sample Input: 10
Sample Output:
Input the size of the square:
####*###*

UNIVERSAL INFORMATICS
www.universalinformatics.comE-mail:info@universaBiformatics.con
CASSIGNMENT

###R##*#*#

301. Write aC programming Write a program that reads in a five-digit integer and determines whether or not
it's a palindrome.
Sample Input: 33333
Sample Output:
Input a five-digit number: 33333 is a palindrome.

302. Write a C programming which reads an integer (7 digits or fewer) and count number of 3s in the given
number.
Sample Input: 538453
Sample Output:
Input a number: The number of threes in the said number is 2

303, Write aC programming to calculate and print the average of some integers. Accept all the values
preceding 888.
Sample Input:12
15
24
888
Sample Output:
Input each number on a separate line (888 to exit):
The averege value of the said numbers is 17.000000

304. Write a C programming to print a table of all the Roman numeral equivalents of the decimal numbers in
the range 1 to 50.
Sample Output:

Decimal Roman
number numeral
--******-***

lli
V

****
LXXXXVilI
39 LXXXXIX
10C C

UNIVERSAL INFORMATICS
www.universalinformatics.comE mail:info@univ. somatics.com

You might also like