Jawaharlal Nehru Technological University Anantapur: (9A05101) Programming in C and Data Structures
Jawaharlal Nehru Technological University Anantapur: (9A05101) Programming in C and Data Structures
Jawaharlal Nehru Technological University Anantapur: (9A05101) Programming in C and Data Structures
JAWAHARLAL NEHRU
TECHNOLOGICAL UNIVERSITY ANANTAPUR
B.Tech. I Year (C.S.E.)
Th Tu C
(9A05101) PROGRAMMING IN C AND DATA STRUCTURES
3 1 6
Unit I- Overview of Computers and Programming – Electronic Computers then and Now,
Computer Hardware, Computer Software, Algorithm, Flowcharts, Software Development
Method, Applying the Software Development Method.
Unit II- Introduction to C Language – C Language Elements, Variable Declarations and Data
Types, Executable Statements, General Form of a C Program, Expressions, Precedence and
Associativity, Expression Evaluation, Operators and Expressions, Type Conversions, Decision
Statements – If and Switch Statements, Loop Control Statements – while, for, do-while
Statements, Nested for Loops, Other Related Statements –break, continue, goto.
Unit III- Functions – Library Functions, Top-Down Design and Structure Charts, Functions
with and without Arguments, Communications Among Functions, Scope, Storage Classes –
Auto, Register, Static, Extern, Scope rules, Type Qualifiers, Recursion – Recursive Functions,
Preprocessor Commands.
Arrays – Declaring and Referencing Arrays, Array Subscripts, Using For Loops for Sequential
Access, Using Array Elements as Function Arguments, Arrays Arguments, Multidimensional
Arrays.
Unit IV- Pointers – Introduction, Features of pointers, Pointer Declaration, Arithmetic
Operations With Pointers, Pointers and Arrays, Pointers and Two-Dimensional Arrays, Array of
Pointers, Pointers to Pointers, Void Pointers, Memory Allocation Functions, Programming
Applications, Pointer to Functions, Command – Line Arguments.
Strings – String Basics, String Library Functions, Longer Strings, String Comparison, Arrays of
Pointers, Character operations, String-To-Number and Number-To-String Conversions, Pointers
and Strings.
Unit V- Structure and Union – Introduction, Features of Structures, Declaration and
Initialization of Structures, Structure within Structure, Array of Structures, Pointer to Structure,
Structure and Functions, typedef, Bit Fields, Enumerated Data Type, Union, Union of Structures.
Unit VI- Files – Introduction, Streams and File Types, Steps for File Operations, File I/O
Structures, Read and Write,_Other File function, Searching Errors in Reading/Writing of Files,
Low Level Disk I/O, Command Line Arguments, Application of Command Line Arguments,
File status functions (error handling).
Unit VII- Data Structures – Overview of Data Structure, Representation of a Stack, Stack
Related Terms, Operation on a Stack, Implementation of a Stack, Representation of Arithmetic
Expressions, Infix, Prefix, and Postfix Notations, Evaluation of Postfix Expression, Conversion
of Expression from Infix to Postfix, Recursion, Queues – Various Positions of Queue,
Representation of Queue, Insertion, Deletion, Searching Operations.
2009-10
Linked List – Singly Linked List, Linked List with and without header, Insertion, Deletion and
Searching Operations.
Unit VIII- Searching and Sorting – Exchange (Bubble) Sort, Selection Sort, Quick Sort,
Insertion Sort, Merge Sort. Searching- Linear and Binary Search Methods.
TEXT BOOKS:
1. Programming in C and Data Structures, J.R. Hanly, Ashok N, Kamthene and
A. Ananda Rao, Pearson Education.
2. C Programming & Data Structures, B.A. Forouzan and R.F. Gilberg, Third Edition,
Cengage Learning.
REFERENCES:
1. Programming in C – Stephen G. Kochan, III Edition, Pearson Education.
2. C Programming with problem solving, J.A. Jones & K. Harrow, Dreamtech Press
3. C and Data Structures, a snapshot oriented treatise with live engineering examples,
Dr. N.B. Venkateswarlu, Dr. E. V. Prasad, S. Chand
4. C and Data Structures, E. Balaguruswamy, Tata Mc Graw Hill
5. Data Structures using C – A. M. Tanenbaum, Y. Langsam, and M. J. Augenstein, Pearson
Education/ PHI, Eighth Edition.
2009-10
JAWAHARLAL NEHRU
TECHNOLOGICAL UNIVERSITY ANANTAPUR
B.Tech. I Year (C.S.E.) Lab C
3 1
Exercise 2.
a) Write a C program to calculate the following Sum:
Sum = 1 – x2/2! + x4/4! – x6/6! + x8/8! – x10/10!
b) Write a C program to find the roots of a quadratic equation.
Exercise 3
a) Write C programs that use both recursive and non-recursive functions.
i). To find the factorial of a given integer.
ii). To find the GCD (greatest common divisor) of two given integers.
iii). To solve Towers of Hanoi problem.
Exercise 4
a) The total distance travelled by vehicle in ‘t’ seconds is given by distance S = ut+1/2at2
where ‘u’ and ‘a’ are the initial velocity (m/sec.) and acceleration (m/sec2) respectively. Write C
program to find the distance travelled 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’.
2009-10
b) Write a C program, which takes two integer operands and one operator from the user,
performs the operation and then prints the result.
(Consider the operators +, -, *, / , % and use Switch Statement)
Exercise 5
a) Write a C program to find both the largest and smallest number in a list of integers.
b) Write a C program that uses functions to perform the following:
i) Addition of Two Matrices ii) Multiplication of Two Matrices.
Exercise 6
a) Write a C program that uses functions to perform the following operations:
i). To insert a sub-string in to a given main string from a given position.
ii). To delete n Characters from a given position in a given string.
b) Write a C program to determine if the given string is a palindrome or not.
Exercise 7
a) Write a C program that displays the position or index in the string S where the string T
begins, or – 1 if S doesn’t contain T.
b) Write a C program to count the lines, words and characters in a given text.
Exercise 8
a) Write a C program to generate Pascal’s triangle.
b) Write a C program to construct a pyramid of numbers.
Exercise 9
Write a C program to read two numbers, x and n, and then compute the sum of the geometric
progression:
1+x+x2+x3+…………..+xn
For example: if n is 3 and x is 5, then the program computes 1+5+25+125.
Print x, n, the sum
Perform error checking. For example, the formula does not make sense for negative exponents –
if n is less than 0. Have your program print an error message if n<0, then go back and read in the
next pair of numbers, without computing the sum. Find if any values of x are also illegal? If so,
test for them too.
Exercise 10
a) 2’s complement of a number is obtained by scanning it from right to left and complementing
all the bits after the first appearance of a 1. Thus 2’s complement of 11100 is 00100. Write a C
program to find the 2’s complement of a binary number.
b) Write a C program to convert a Roman numeral to its decimal equivalent.
Exercise 11
2009-10
Exercise 12
a) Write a C program which copies one file to another.
b) Write a C program to reverse the first n characters in a file.
(Note: The file name and n are specified on the command line.)
Exercise 13
a) Write a C program to display the contents of a file.
b) Write a C program to merge two files into a third file (i.e., the contents of the first file
followed by those of the second are put in the third file.)
Exercise 14
Write a C program that uses functions to perform the following operations on singly linked list:
i) Creation ii) Insertion iii) Deletion iv) Traversal
Exercise 15
Write a C program that implement stack (its operations) using
i) Arrays ii) Pointers
Exercise 16
Write C program that implement Queue (its operations) using
i) Arrays ii) Pointers
Exercise 17
Write a C program that uses Stack operations to perform the following:
i) Converting infix expression into postfix expression
ii) Evaluating the postfix expression
Exercise 18
Write a C program that implements the following sorting methods to sort a given list of integers
in ascending order
i) Bubble sort ii) Selection sort
Exercise 19
Write C programs that use both recursive and non recursive functions to perform the following
searching operations for a Key value in a given list of integers:
2009-10
Exercise 20
Write C program that implements the Quick sort method to sort a given list of integers in
ascending order.
Exercise 21
Write C program that implement the Merge sort method to sort a given list of integers in
ascending order.
Exercise 22
Write C programs to implement the Lagrange interpolation and Newton- Gregory forward
interpolation.
Exercise 23
Write C programs to implement the linear regression and polynomial regression algorithms.
Exercise 24
Write C programs to implement Trapezoidal and Simpson methods.
REFERENCE BOOKS:
1. Programming in C and Data Structures, J.R. Hanly, Ashok N, Kamthene and
A. Ananda Rao, Pearson Education.
2. The Spirit of C, an introduction to modern programming, M.Cooper, Jaico Publishing
House.
3. Mastering C, K.R. Venugopal and S.R. Prasad, TMH Publications
4. Computer Basics and C Programming, V. Rajaraman, PHI Publications.