Saturday, December 11, 2010

C PROGRAMMING LAB (Common to all Branches)

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY KAKINADA
C PROGRAMMING LAB (Common to all Branches)
Syllabus effective from 2010 -2011
Objectives:
 To learn/strengthen a programming language like C, To learn problem solving techniques
Recommended Systems/Software Requirements:
 Intel based desktop PC, ANSI C Compiler with Supporting Editors, IDE’s such as Turbo C,
Bloodshed C,
 Linux with gcc compiler
Exercise l
Solving problems such as temperature conversion, student grading, income tax calculation, etc., which expose
students to use basic C operators
Exercise 2
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.
Exercise 3
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.
d) Write a program which checks a given integer is Fibonacci number or not.
Exercise 4
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 5
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)
Exercise 6
a) Simple programming examples to manipulate strings.
b) Verifying a string for its palindrome property
Exercise 7
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.
iii. To replace a character of string either from beginning or ending or at a specified location
Exercise 8
Write a C program that uses functions to perform the following operations using Structure:
i) Reading a complex number ii) Writing a complex number
iii) Addition of two complex numbers iv) Multiplication of two complex numbers
Exercise 9
a) Addition of Two Matrices
b) Calculating transpose of a matrix in-place manner.
c) Matrix multiplication by checking compatibility
Exercise 10
a) Write C programs that use both recursive and non-recursive functions for the following
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 11
a) Write a C functions to find both the largest and smallest number of an array of integers.
b) Write a C function that uses functions to perform the following:
i) that displays the position/ index in the string S where the string T begins, or –1 if S doesn’t contain
T.
ii) to count the lines, words and characters in a given text.
Exercise 12
a) Write a C function to generate Pascal’s triangle.
b) Write a C function to construct a pyramid of numbers.
Exercise 13
Write a C function to read in two numbers, x and n, and then compute the sum of this geometric progression:
1+x+x2+x3+………….+xn
Write a C function to read in two numbers, x and n(no. of terms), and then compute sin(x) and cos(x).
Exercise 14
a. Pointer based function to exchange value of two integers using passing by address.
b. Program which explains the use of dynamic arrays.
c. Program to enlighten dangling memory problem (Creating a 2-D array dynamically using pointer to
pointers approach.
Exercise 15
Examples which explores the use of structures, union and other user defined variables
Exercise 16
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)
***

No comments:

Post a Comment