Vous êtes sur la page 1sur 6

LABORATORY MANUAL

CS-4205 Programming and Problem Solving Using C


July 2012 Onwards

Devi Ahilya Vishwavidyalaya


School of Computer Science & IT

We make things happen . . .


Producing world class
IT Professionals
Since 1986
www.scs.dauniv.ac.in

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.

SCHOOL OF COMPUTER SCIENCE & IT


DEVI AHILYA VISWAVIDYALAYA
Takshashila Campus, Khandwa Road, Indore 452017
Tel. (0731) 2470027, 2461548 Fax : (0731) 2763618
Email: head.scs@dauniv.ac.in

CS-4205 Programming and Problem Solving Using C


AIM:
To enable students in developing programming skills using C language. To improve their
logical ability and to apply these skills for solving problems in scientific, mathematical and
business applications.

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

41. Find value of a given Fibonacci term


42. Swapping the values of two variable
43. Minimum/maximum value from the given input
44. Input todays date and Print yesterdays date. You can use the ANSI standard
functions 'time' and 'ctime'. An example of the O/P from my program is Fri
Mar 17 18:46:47 1995
LAB TEST-II
45. Write User Defined Function and test them in the main program for the
following standard function
a. int myatoi(Char *s)
b. char *myitoa(int i)
c. int mystrlen(char *s)
d. char *mysubstr(char *s, int i, int j)
e. char *mystrcat(char *s1,char *s2)
f. int mystrcmp(char *s1, char *s2)
g. int mystrchr(char *s, char c, int i)
h. char *mystrrev(char *s)
i. int mystrend(char *s, char *t)
j. char *myreplace(char *s, char *old, char *new)
k. int abs(int i)
l. char *mytoupper(char *)
m. char *mytolower(char*)
n. int isupper(char *s)
o. int islower(char *s)
p. int mypower(int a, int b)
q. int mymod (int a, int b)
46. Write the following recursive C Function
a. Factorial of a given number
b. Nth Fibonacci number
c. Reverse of a given String
d. Reverse of a give Number
e. Sin(x)
47. Write a c program to create a new data type Date with the help of structure and
typedef. Also write following user defined function for date manipulation.
a. To return next Date,
b. To return next Month,
c. To return next Year,
d. To add few Days in a date
e. To add few Months in a date
f. To add few Years in a date
g. To return the date of the week of a given date.
h. To return Month name from the date.
i. To Display the Date in various format as:
Date Display(Date d1, char *format)Here Date is the newly created data type.
The format string can hold the following values:DDMMYYYY, MMDDYY,
MON, DD, YYYY
48. Write a C program to implement myprintf and myscanf functions using

Week 14

Week 15

Concept of variable number of arguments.


49. (using getch, putch, gets and puts function)
50. Write a C program that creates an Employee text file? Records Are empid,
empname, designation, qualification, salary, experience, Research work,
address, city phone?
51. Write a C program that manipulates the above text file. The program must
implements the operation to modify a record, delete a record and append new
records.
52. Write C programs for the following operation to work like DOS Commands:
a. type abc.txt
b. copy source1.txt source2.txt
c. copy source1.txt source2.txt source3.txt source4.txt
d. compare source1.txt source2.txt
e. concat source1.txt source2.txt
53. Write a C program to open two files containing integers (in sorted order) and
merge their contents.
54. Write a C program to count the number of vowels, consonants, digits, spaces,
other symbols, words and lines in a given text file.
55. Write C code to check if an integer is a power of 2 or not
56. Write a C program to count bits set in an integer?
57. Write a C program to set a particular bit in a given number.
58. Write a C program to reset a particular bit in a given number.
LAB TEST-III
Revision and Tutorial

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.

*****************

Vous aimerez peut-être aussi