Tuesday, September 22, 2009

COMPUTER PROGRAMMING LAB


JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY

HYDERABAD

I Year B.Tech EEE

COMPUTER PROGRAMMING LAB

Objectives:

· To make the student learn a programming language.

· To teach the student to write programs in C solve the problems

· To Introduce the student to simple linear and non linear data structures such as lists, stacks, queues, trees and graphs.

Recommended Systems/Software Requirements:

· Intel based desktop PC

· ANSI C Compiler with Supporting Editors

Week l.

a) Write a C program to find the sum of individual digits of a positive integer.

b) A Fibonacci Sequence is defined as follows: the first and second terms in the sequence are 0 and 1. Subsequent terms are found by adding the preceding two terms in the sequence. Write a C program to generate the first n terms of the sequence.

c) Write a C program to generate all the prime numbers between 1 and n, where n is a value supplied by the user.

Week 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 toe find the roots of a quadratic equation.

Week 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.

Week 4

a) The total distance travelled by vehicle in ‘t’ seconds is given by distance = ut+1/2at2 where ‘u’ and ‘a’ are the initial velocity (m/sec.) and acceleration (m/sec2). 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’.

b) Write a C program, which takes two integer operands and one operator form the user, performs the operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch Statement)

Week 5

a) Write a C program to find both the larges 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

Week 6

a) Write a C program that uses functions to perform the following operations:

i) To insert a sub-string in to 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

Week 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.

Week 8

a) Write a C program to generate Pascal’s triangle.

b) Write a C program to construct a pyramid of numbers.

Week 9

Write a C program to read in two numbers, x and n, and then compute the sum of this 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 of without computing the sum. Are any values of x also illegal ? If so, test for them too.

Week 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.

Week 11

Write a C program that uses functions to perform the following operations:

i) Reading a complex number

ii) Writing a complex number

iii) Addition of two complex numbers

iv) Multiplication of two complex numbers

(Note: represent complex number using a structure.)

Week 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.)

Week 13

Write a C program that uses functions to perform the following operations on singly linked list.:

i) Creation ii) Insertion iii) Deletion iv) Traversal

Week 14

Write a C program that uses functions to perform the following operations on doubly linked list.:

i) Creation ii) Insertion iii) Deletion iv) Traversal in both ways

Week 15

Write C programs that implement stack (its operations) using

i) Arrays ii) Pointers

Week 16

Write C programs that implement Queue (its operations) using

i) Arrays ii) Pointers

Week 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

Week 18

Write a C program that uses functions to perform the following:

i) Creating a Binary Tree of integers

ii) Traversing the above binary tree in preorder, inorder and postorder.

Week 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 :

i) Linear search ii) Binary search

Week 20

Write C programs that implement the following sorting methods to sort a given list of integers in ascending order:

i) Bubble sort ii) Quick sort

Week 21

Write C programs that implement the following sorting methods to sort a given list of integers in ascending order:

i) Insertion sort ii) Merge sort

Week 22

Write C programs to implement the Lagrange interpolation and Newton- Gregory forward interpolation.

Week 23

Write C programs to implement the linear regression and polynomial regression algorithms.

Week 24

Write C programs to implement Trapezoidal and Simpson methods.

Text Books

1. C programming and Data Structures, P. Padmanabham, Third Edition, BS Publications

2. Data Structures: A pseudo code approach with C, second edition R.F. Gilberg and B.A. Forouzan

3. Programming in C, P.Dey & M. Ghosh, Oxford Univ.Press.

4. C and Data Structures, E Balaguruswamy, TMH publications.

C lab programs

C LAB PROGRAMS WEEK WISE

I AM POSTING 10 WEEK PROGRAMS

LATER IW ILL UPLOAD REMAING 10 WEEK PROGRAMS

WEEK1

CODE

http://www.ziddu.com/download/3456050/WEEK1.rar.html

WEEK2

CODE

http://www.ziddu.com/download/3456048/WEEK2.rar.html

WEEK3

CODE

http://www.ziddu.com/download/3456042/WEEK3.rar.html

WEEK4

CODE

http://www.ziddu.com/download/3456047/WEEK4.rar.html

WEEK5

CODE

http://www.ziddu.com/download/3456046/WEEK5.rar.html

WEEK6

CODE

http://www.ziddu.com/download/3456043/WEEK6.rar.html

WEEK7

CODE

http://www.ziddu.com/download/3456049/WEEK7.rar.html

WEEK8

CODE

http://www.ziddu.com/download/3456041/WEEK8.rar.html

WEEK9

CODE

http://www.ziddu.com/download/3456045/WEEK9.rar.html

WEEK10

CODE

http://www.ziddu.com/download/3456044/WEEK10.rar.html

BALAGURUSWAMI solved problems

http://www.ziddu.com/download/3311602/BALAGURUSAMY.rar.html

C PROGRAMMING & DATA STRUCTURES

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY

HYDERABAD

I Year B.Tech EEE

C PROGRAMMING AND DATA STRUCTURES

UNIT - I

Algorithm / pseudo code, flowchart, program development steps, structure of C program, A Simple C program, identifiers, basic data types and sizes, Constants, variables, arithmetic, relational and logical operators, increment and decrement operators, conditional operator, bit-wise operators, assignment operators, expressions, type conversions, conditional expressions, precedence and order of evaluation.

Input-output statements, statements and blocks, if and switch statements, loops- while, do-while and for statements, break, continue, goto and labels, programming examples.

UNIT - II

Designing structured programs, Functions, basics, parameter passing, storage classes- extern, auto, register, static, scope rules, block structure, user defined functions, standard library functions, recursive functions, header files, C preprocessor, example c programs.

UNIT - III

Arrays- concepts, declaration, definition, accessing elements, storing elements, arrays and functions, two-dimensional and multi-dimensional arrays, applications of arrays. pointers- concepts, initialization of pointer variables, pointers and function arguments, address arithmetic, Character pointers and functions, pointers to pointers, pointers and multidimensional arrays, dynamic memory managements functions, command line arguments, c program examples.

UNIT - IV

Derived types- structures- declaration, definition and initialization of structures, accessing structures, nested structures, arrays of structures, structures and functions, pointers to structures, self referential structures, unions, typedef, bitfields, C program examples.

UNIT - V

Input and output – concept of a file, text files and binary files, streams, standard I/o, Formatted I/o, file I/o operations, error handling, C program examples.

UNIT - VI

Searching – Linear and binary search methods, sorting – Bubble sort, selection sort, Insertion sort, Quick sort, merge sort.

UNIT – VII

Introduction to data structures, singly linked lists, doubly linked lists, circular list, representing stacks and queues in C using arrays and linked lists, infix to post fix conversion, postfix expression evaluation.

UNIT - VIII

Trees- Binary tress, terminology, representation, traversals, graphs- terminology, representation, graph traversals (dfs & bfs)

TEXT BOOKS :

1. Computer science, A structured programming approach using C, B.A. Forouzan and R.F. Gilberg, Third edition, Thomson.

2. DataStructures Using C – A.S.Tanenbaum, Y. Langsam, and M.J. Augenstein, PHI/Pearson education.

REFERENCES :

1. C& Data structures – P. Padmanabham, B.S. Publications.

2. The C Programming Language, B.W. Kernighan, Dennis M.Ritchie,

PHI/Pearson Education

3. C Programming with problem solving, J.A. Jones & K. Harrow,

dreamtech Press

4. Programming in C – Stephen G. Kochan, III Edition, Pearson Eductaion.

5. Data Structures and Program Design in C, R.Kruse, C.L. Tondo, BP Leung, Shashi M, Second Edition, Pearson Education.