Laboratory Manual: CS-4205 Programming and Problem Solving Using C
Laboratory Manual: CS-4205 Programming and Problem Solving Using C
MISSION OF SCS
To produce world-class professionals who have excellent analytical
skills, communication skills, team building spirit and ability to work in
cross cultural environment.
To produce international quality IT professionals, who can
independently design, develop and implement computer applications.
Professionals who dedicate themselves to mankind.
OBJECTIVES:
The objectives of the course are :
To get students understand and solve logical and mathematical problems through
algorithms and flowcharts.
To know programming methodologies using C language.
To design and develop solutions to intermediate level problems using the C language.
Further develop their skills in software development using a procedural language (the
C language).
Experiments list
WEEK
Week 1
Week 2
Week 3-4
PRACTICAL LIST
Write a C program to display "Hello Computer" on the screen.
Write a C program to display Your Name, Address and City in different lines.
Write a C program to find the area of a circle using the formula: Area = PI * r2
Write a C program to find the area and volume of sphere. Formulas are: Area =
4*PI*R*R Volume = 4/3*PI*R*R*R.
5. Write a C program to print the multiply value of two accepted numbers
6. Write a C program to convert centigrade into Fahrenheit. Formula: C= (F32)/1.8.
7. WWrite a C program to read in a three digit number produce following output
(assuming that the input is 347)
3 hundreds
4 tens
7 units
8. Write a C program to read in two integers and display one as a percentage of
the other. Typically your output should look like
20 is 50.00% of 40
assuming that the input numbers where 20 and 40. Display the percentage
correct to 2 decimal places.
9. Write a C program to find out whether the character presses through the
keyboard is a digit or not (using conditional operator).
10. Write a C program to swap variable values of i and j.
1.
2.
3.
4.
11. Write a C program to find the maximum from given three nos.
12. Write a C program to find that the accepted no is Negative, Positive or Zero.
13. Write a program which reads two integer values. If the first is lesser print the
Week 5
Week 6
Week 7
message up. If the second is lesser, print the message down if they are equal,
print the message equal if there is an error reading the data, print a message
containing the word Error.
14. Write a C program that prints the given three integers in ascending order using
if else.
15. Given as input three integers representing a date as day, month, year, print the
number day, month and year for the next day's date.
Typical input: 28 2 1992 Typical output: Date following 28:02:1992 is
29:02:1992.
16. Write a C program for calculator designing using switch /case loop?
17. Write a C program to convert decimal to binary.
18. Write a C program to convert decimal to octal.
19. Write a C program to convert decimal to hexadecimal.
20. Write a C program to find the sum of first 100 natural nos.
21. Produce a multiplication table. Top left hand corner will show 1x1 and bottom
right shows 12x12, as below.
1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 14 16 18 20 22 24
3 6 9 12 15 18 21 24 27 30 33 36
4 8 12 16 20 24 28 32 36 40 44 48
5 10 15 20 25 30 35 40 45 50 55 60
6 12 18 24 30 36 42 48 54 60 66 72
7 14 21 28 35 42 49 56 63 70 77 84
8 16 24 32 40 48 56 64 72 80 88 96
9 18 27 36 45 54 63 72 81 90 99 108
10 20 30 40 50 60 70 80 90 100 110 120
11 22 33 44 55 66 77 88 99 110 121 132
12 24 36 48 60 72 84 96 108 120 132 144
22. Write a C program to find the sum of first 100 odd nos. and even nos.
23. Write a C program to display first 25 Fibonacci nos.
24. Write a C program to display first 100 prime nos.
25. Write a C program to find factorial of accepted nos.
26. Write a C program to find the sum of digits of accepted no.
27. Write a program in C that will scan a number N and then output
the sum of the powers from 1 to N. thus, if the input is 4, the output should be
288 bec. 1+4+27+256=288 [1,2,3,4]
28. Write a program in C that accepts dates written in numerical form and then
output them as a complete form.
Sample input: 2 26 1986
Sample output: February 26, 1986.
LAB TEST-I
29. Write a C program to print the accepted no and its reverse no.
30. Write a C program to print all the Factors of accepted no.
31. Write a C program to find HCF of two given numbers.
32. Write a C program to find LCM of two given numbers.
33. Write a C program to find all the prime number between two given numbers.
34. The National Earthquake Information Center has the following criteria to
Week 8
Week 9
determine the earthquake damages. Here is the given richter scale serve as an
input data and the characterization as output information.
RICHTER NUMBER (N)....CHARACTERIZATION
N<5.0---------little or no damage
5.0<=N<5.5-----some damage
5.5<=N<6.5.---serious damage
6.5<=N<7.5----Disaster
Higher.---------Catastrophe
35. Write C programs to print the terms of each of the following series:
i. Sin(x) ii. Cos(x) iii. Log (1+x) iv. log(1-x) v. ex vi. e-x
36. Display the following output on screen (assuming the value for input
parameter n=5) :
a.
b.
c.
d.
*
1
A
1
**
12
AB
23
***
123
ABC
345
****
1234
ABCD
4567
*****
12345
ABCDE
56789
f.
g.
h.
i.
*****
ABCDE
*
1
****
ABCD
***
123
***
ABC
*****
12345
**
AB
*******
1234567
*
A
*********
123456789
k.
l.
m.
n.
*
ABCDE
1
*****
**
ABCD
12
0000
***
ABC
123
***
****
AB
1234
00
*****
A
12345
*
p.
q.
r.
s.
1
1
A
ABCDEDCBA
01
22
AB
ABCD DCBA
101
333
ABC
ABC
CBA
0101
4444
AB
AB
BA
10101
55555
A
A
A
36. Write a C program to find minimum, maximum, sum and average of the given
one dimensional array.
37.
Write a C program to perform the basic Matrix operations
addition,
subtraction, multiplication, Transpose.
38. Write a program to take a sentence as input and reverse every word of the
sentence.
39. Write a C Function for the following task
40. Calculating Factorial
e.
1
23
456
78910
1011121
j.
1
121
12321
1234321
1234543
o.
1
10
101
1010
10101
t.
1
121
12321
1234321
1234543
21
Week 1011
Week 12
Week 13
Week 14
Week 15
Resources:
B.W. Kernighan, D.M. Ritchie, The C Programming Language, Prentice Hall of India.
E Balagurusami, Programming in ANSI C, Tata McGraw-Hill.
Byron S Gottfried, Programming with C, Tata McGraw-Hill.
Yashwant Kanetkar, Test your C skills,BPB Publication.
Behrouz A. Forouzan, Richard F. Gilberg, Computer Science: A Structured
Programming Approach Using C, Second Edition, Thomson Brooks/cole.
*****************