Sie sind auf Seite 1von 4

C Programming - Practical Assignments

1. Menu driven program to add ,delete, Modify records and Display record of the employee attendance in a IT
company using binary file.

2. Write a program to implement command line arguments like opening and closing
a file and enter text in file and display content with statistics.

3. Write a program using dynamic memory allocation and pointers to construct an ordered doubly linked list
based on the experience of the employee, where each node consists of the following information: Employee id
(integer ) ,Employee name (character string ) and experience ( integer ) .

4. Write a program for implementing stack of strings using linked list and display output.

5. Write a C Program to construct a stack of integers and to perform the following operations on it
push
pop
display
The program should print appropriate messages for stack overflow, stack underflow and stack
empty.

6. Write a single C program to perform each of the following:


Create a queue of N elements
Reverse the queue so that last element becomes first & so on .

7. Write a single C program to perform each of the following:


Insert an element in between ith and i+1-th the elements of the original queue.
Print the contents of r-th element of the queue after the third and fourth operations .

8. Write a program to using files to encrpt and decrypt .Use 2 separate files for output Use command line
arguments.

9. Write a C program for searching a book in a library catalogue containing the following fields: Accno, title,
publisher (use structure data type). The program should facilitate to both add book records as well as to search
a particular book .The
searching is through (i) titlewise
(ii) authorwise
(iii)publisher wise

10. Write a function to generate the following pyramid of numbers

0
101
21012
3210123
432101234
54321012345
432101234
3210123
21012
101
0

11. Write a program that maintains an address book. This program adds the detail of the contact to the file
“add_book.dat” .The program also gives the user a choice of functions like
Add a contact
Display contact
Modify the details of a contact
Delete a contact
12. Define a structure to represent time in hours (0-23), minutes (0-59), and seconds (0-59), and then write a
function that accepts an argument of type time represented by this structure and updates it by one second & 30
seconds.

13. Write a program to sort a number of strings using bubble sort. Input is a number of strings and the output is
the sorted list based on the length of strings.

For eg: If input is jyoti, sareeka, anisha, sangita, savita, suja


The output is suja, jyoti, anisha, savita, sareeka, sangita

14. Write a program to find the difference between any 2 dates. The output should be in days.

15. Write a function squeeze(s1,s2) that deletes each character in string s1 that matches any character in string
s2.

16. Write a program to cyclically permute a string one character at a time.


e.g. : If space is the input the output should produce
space
paces
acesp
cespa
espac

17. Write a C function to add, subtract and multiply that read two strings of 0s and 1s representing binary non-
negative integers, and print the string representing their sum, differences and product respectively.

18. Write a program to create a data file for storing student records. Create a linked list and keep adding the
nodes to the list as and when a new record is added to the file. The structure of the linked list is as follows:
struct index
{
long location;
long key;
struct index *next;
};
The field location stores the offset values of the records in the file. Use this linked list to search a record on the
basis of a given key value.

19. The Confusion Unlimited has three investment schemes : simple interest of 20%, compound interest of 18%
compounded annually, and compound interest of 15% compounded every six months. Write a program that
reads the amount and the time for which the money is to be invested, and advise the best choice of scheme.

20. A square matrix, that is, one having the same number of rows and columns, is called a diagonal matrix if its
only non-zero elements are on the diagonal. It is called upper triangular if all elements below the diagonal are
zero, and lower triangular if all elements above the diagonal are zero. Write a program that determines if a
given square matrix is one of these matrices.

21. Create a text file using any editor. The text file contains a distinct word on each line. Read the text file into a
doubly linked list and traverse the list from both the ends.

22. Write a program to maintain a doubly linked list having the following functions :
a. Creation of the list.
b. Adding node at the end of the list.
c. Displaying the list by traversing from both ends.
d. Counting the number of nodes in the list.

23. Create a text file using any simple editor. Write a program, which uses this text file as input and creates
another file with the odd and even positioned characters swapped.

24. Write a program that will reverse each word in a file and store it in another file.
25. Write a program to search a word from a text file.
a. If the word is found print a message that the word is found along with the position of the word in the file.
b. If the word is not found, print the message that the word is not found along with the total number of
words in the file.

26. Write a program to print the strings from a text file in reverse order using a stack of strings.

27. Write a program to extract specified lines of text from a text file.
Create 2 data files. One for input and one for output.
Accept the line numbers from the user and extract the data from input file corresponding to those line
numbers and store
the data of those line numbers in the output file.

28. Write a program to accept the day and the year , and print the date along with the month.
For eg:If the input is 59 1999 , the output should be 21 February

29. Using pointers write your own functions for the following:
a. String comparison
b. String concatenate
c. String copy
d. String length.

Note : Do not include <string.h> in your program

30. There are 10 records present in a file with the following structure :
struct
{
char itemcode[6];
char itemname [20];
int qty;
};
Write a program to read these records and display them in ascending order on the field itemname and write
them into a text file in ascending order.

31. Write a program to remove all C comments from a file.

32. Write a program to implement a mail merge facility.

33. Write a program to maintain a singly linked list having the following functions:
a. Creation of the list.
b. Displaying the list.
c. Traverse through the linked list and add contents of two consecutive nodes. The result should be
inserted soon after the nodes added.
Note: If the linked list contains the data : 5 15 8 9 2 6
The new linked list should contain the data in the following order : 5 15 20 8 9 17 2 6 8.
Display both the original linked list as well as the new linked list.

34. A common mistake in typing is that the same word is typed more than once. Write a program that finds such
double words and the line numbers on which they occur in input. A sentence may span more than one line, and
there nay be more than one sentence on one line.

35. Write a program for creating a sorted doubly linked list.

36. Write a program that, for all positive integers i,j,k and l from 1 through 1000, determines all combinations of
i, j, k and l such that i+j+k=l and i<j<k<l.
37. Write a program using nested loops to generate the following pattern:
zyxwvwxyz
zyxwxyz
zyxyz
zyz
z

38. A perfect square is an integer, which is the square of another integer. Write a program that reads a number
and computes the first perfect square larger than this number.

39. Write a program to maintain a singly linked list having the following functions :
a. Creation of the list.
b. Displaying the list.
c. Traverse through the linked list and subtract two consecutive nodes .The result should be inserted
just before the nodes subtracted.

Note: If the linked list contains the data :


5 15 8 9 2 6
The changed linked list should contain the data in the following order:
-10 5 15 -1 8 9 -6 2 6 .
Display both the original linked list as well as the changed linked list.

40. Write functions for the following base conversion operations :


a. Octal to Hexadecimal.
b. Hexadecimal to Octal.
Take care to validate digits/characters while accepting the input.

41. Write a program that will read each line in a file and store it in another file with the sequence reversed, that
is, the first line in file one should be the last line in file two and so on.

42. Write a program to maintain a singly linked list having the following functions:
a. Creation of the list.
b. Displaying the list.
c. Swap all nodes at consecutive even and odd positions.
Note: The node at position 1 should be swapped with node 2, node 3 with that of node 4, node 5 with 6
and so on.

43. Design a function instring(char *str1,char *str2), where instring() searches out the existence of string str2 in
str1 and reports the same. It should also display the number of occurrences of str2 in str1. Implement the
function in a C-code.

44. Create a text file using any editor. The text file contains a distinct word on each line. Read the text file into a
Singly linked list and display the count of words.

45. Write a program to maintain a singly linked list having the following functions:
a. Creation of the list.
b. Displaying the list.
c. Traverse through the linked list and pick all the odd numbered nodes and place them in the
beginning of the list and the rest will be all the even numbered nodes.
Note: If the linked list contains the data : 5 15 8 9 26
The changed linked list should contain the data in the following order:
5 8 26 15 9 .

Das könnte Ihnen auch gefallen