Thursday, November 13, 2008

C programs + flow chart

Gandhiji Institute Of Science & Technology Jaggiahpet-521175


Department of Computer Sciences

C and data structures
Lab Manual [Subject Code : CS ]
For the Academic year 2008-09
I B Tech – [Common to all Branches]
Document No: Verified By
Version: HOD CSE

Gandhiji Institute Of Science & Technology Jaggiahpet-521175
Department of Computer Science

LAB MANUAL FOR THE ACADEMIC YEAR 2008-09





SUB : C & DATA STRUCTURES

SUB CODE :

STREAM : COMMON TO ALL BRANCHES

INSTRUCTORS : 1.
2.

PROGRAMMERS : 1.

VENUE : LAB I/III (GROUND FLOOR)
BLOCK : CSE
INDEX

S.No CONTENT Page. No Credits/
Grads Faculty
Signature Remarks
If any
1 Introduction About Lab 4
2 Guidelines to Students 6
3 List of Lab Exercises
Syllabus Programs (JNTU)
7
4 Solutions for Programs 10
5 References 237


Result: ________________ Signature of the faculty incharge


INTRODUCTION:
ABOUT LAB:
There are 66 systems (Compaq Presario) installed in this Lab. Their configurations are as follows:
Processor : AMD Athelon ™ 1.67 GHz
RAM : 256 MB
Hard Disk : 40 GB
Optical Drive : 52X CD-ROM
Monitor : 15” CRT Color Monitor
Mouse : Optical Mouse
Key Board : 105 MMX Key Board
Network Topology : Star Topology
Network Interface card : Present

Software
1 All systems are configured in DUAL BOOT mode i.e, Students can boot from Windows XP or Linux as per their lab requirement.
This is very useful for students because they are familiar with different Operating Systems so that they can execute their programs in different programming environments.
2 Each student has a separate login for database access
Oracle 9i client version is installed in all systems. On the server, account for each student has been created.
This is very useful because students can save their work ( scenarios’, pl/sql programs, data related projects ,etc) in their own accounts. Each student work is safe and secure from other students.
3 Latest Technologies like DOT NET and J2EE are installed in some systems. Before submitting their final project, they can start doing mini project from 2nd year onwards.
4 MASM ( Macro Assembler ) is installed in all the systems
Students can execute their assembly language programs using MASM. MASM is very useful students because when they execute their programs
They can see contents of Processor Registers and how each instruction is being executed in the CPU.
1. Rational Rose Software is installed in some systems
Using this software, students can depict UML diagrams of their projects.
2 Softwares installed: C, C++, JDK1.5, MASM, OFFICE-XP, J2EE and DOT NET, Rational Rose.

3 Systems are provided for students in the 1:1 ratio.

4 Systems are assigned numbers and same system is allotted for students when they do the lab.

GUIDELINES TO STUDENTS:


1 Equipment in the lab for the use of student community. Students need to maintain a proper decorum in the computer lab. Students must use the equipment with care. Any damage is caused is punishable.
2 Students are required to carry their observation / programs book with completed exercises while entering the lab.
3 Students are supposed to occupy the machines allotted to them and are not supposed to talk or make noise in the lab. The allocation is put up on the lab notice board.
4 Lab can be used in free time / lunch hours by the students who need to use the systems should take prior permission from the lab in-charge.
5 Lab records need to be submitted on or before date of submission.
6 Students are not supposed to use floppy disks


LIST OF LAB EXERCISES:

PROGRAMS (AS PER JNTU SYLLABUS)
S No Name of the program Page no
WEEK1

a)
b)
c) Write C Programs for the Following
Sum of digits of a given number
Write a program to print Fibonacci series
To print prime up to n no
WEEK 2
a)

b) Write a C program to calculate the following Sum:
Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10!
Write a C program to find the roots of a quadratic equation.
WEEK 3



a)
b) Write C Programs in both using recursive and non-recursive methods to find the following

Factorial of a given number
To find the GCD (greatest common divisor) of two given integers

WEEK 4
a)
b)
To perform the arithmetic expression using switch statement
WEEK 5
a)

b) Write a C program to find both the largest and smallest number in a list of integers
Write a C program that uses functions to perform the following:
i) Multiplication of Two Matrices
ii) Addition of Two Matrices
WEEK 6
a)




b) Write a C Program that uses functions to perform the following operations
i) To insert a given substring in to given main string from a given position
ii) To delete n Characters from a given position in a given string.
Write a C program to determine if the given string is a palindrome or not
WEEK 7
a)

b) 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.
Write a C program to count the lines, words and characters in a given text
WEEK 8
a)
b) Write a C program to generate Pascal's triangle.
Write a C program to construct a pyramid of numbers

WEEK 9
a) 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)




b) 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.
Write a C program to convert a Roman numeral to its decimal equivalent
WEEK 11
Write a C Program that performs the following
i) Reading a Complex number
ii) Writing a Complex number
iii) Addition of two Complex numbers
iv) Multiplication of two numbers
Note: represent complex number using a structure
WEEK 12
a)
b) Write a c Program which copies one file to another
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 single 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 double linked list.:
i) Creation
ii) Insertion
iii) Deletion
iv) Traversal

WEEK 15
Stack operations using i) arrays ii) Pointers
WEEK 16
C programs that implement queue (its operations) using
i) Arrays ii) pointers
WEEK 17
a)
b) Infix-postfix operations
Prefix-evaluation
WEEK 18
a) 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
a)
b) Linear search
Binary search
WEEK 20
Bubble sort
Quick sort
WEEK 21
a)
b) Insertion sort
Merge sort
WEEK 22
a) Write C program to implement the Legrange Interpolation and Newton- Gregory forward interpolation
WEEK 23
a) Write C program to implement the linear regression and polynomial
WEEK 24
a) Write C program to implement Trapezoidal method and Simpson method.

SOLUTIONS FOR PROGRAMS (AS PER JNTU SYLLABUS)

WEEK 1

Name of the Experiment:

a) AIM: Program to find sum of digits of a number
Software/Hardware Requirements:

S/W: Turbo C, Office XP, Windows NT Server with Service Pack
H/W: Pentium IV, Intel Mother Board Processor, 40 GB HDD, 256 MB RAM

ALGORITHM:
Step1:start
Step2:input n,r,s
Step3:s=0
Step4:d=n%10
Step5:s=s+d
Step6:n=n/10
Step7: is n!=0
Step8: repeat step 4 to step 6 till step 7 is true
Step9:when step 7 falls
Step10:print s
Step11:stop


Test Data:

Valid Data Set:
Invalid Data Set:
Limiting Data Sets:

Name of the Experiment:

b) AIM: Program to print Fibonacci series

Software/Hardware Requirements:

S/W: Turbo C, Office XP, Windows NT Server with Service Pack
H/W: Pentium IV, Intel Mother Board Processor, 40 GB HDD,256 MB RAM

ALGORITHM:
Step1: start
Step2: read I, x, f,f1,f2
Step3: f=0,f1=1,f2=1
Step4: do
I++
F1=f2
F2=f
F=f1+f2
While (i<=n)
Step5: print f
Step6: stop



Test Data:

Valid Data Set:
Invalid Data Set:
Limiting Data Sets:

Name of the Experiment:

c) AIM: Program to generate prime number till nth number

Software/Hardware Requirements:

S/W: Turbo C, Office XP, Windows NT Server with Service Pack
H/W: Pentium IV, Intel Mother Board Processor, 40 GB HDD,256 MB RAM

ALGORITHM:
Step1: start
Step2: read n value
Step3: for i=1 i<=n
Step4: repeat a b c d e
a)factorial equal to 0
b) for i=1,j<=1 repeat c,d
c)if i percentage j equal to zero
d) fact equal to factorial added with one
e) if factorial equal to2print as prime number
Step5: display the prime no till nth num
Step56: stop


Test Data:

Valid Data Set:
Invalid Data Set:
Limiting Data Sets:

WEEK 2

Name of the Experiment:

a) AIM: Write a C program to calculate the following Sum:
Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10!

Software/Hardware Requirements:

S/W: Turbo C, Office XP, Windows NT Server with Service Pack
H/W: Pentium IV, Intel Mother Board Processor, 40 GB HDD,256 MB RAM

ALGORITHM :

Step1: Start
Step2: read counter,f_coun,x,power,fact
Step3: for(counter=0, power=0; power<=10; counter++,power=power+2)
fact=1
Step4: for(f_coun=power; f_coun>=1; f_coun--)
fact *= f_coun
Step5: sum=sum+(pow(-1,counter)*(pow(x,power)/fact));
Step6: print sum
Step7: Stop


Test Data:

Valid Data Set:
Invalid Data Set:
Limiting Data Sets:

Name of the Experiment:

b) AIM: Write a C program to find the roots of a quadratic equation.

Software/Hardware Requirements:

S/W: Turbo C, Office XP, Windows NT Server with Service Pack
H/W: Pentium IV, Intel Mother Board Processor, 40 GB HDD,256 MB RAM

ALGORITHM:

Step1: Start
Step2: read a,b,c
Step3: d=sqrt(b*b-4*a*c)
Step4: if(d==0)
Root1=-b/2*a
Root2=-b/2*a
print Root1,Root2
Step5: else if(d>0)
Root1=-d/2*a
Root2=d/2*a
print Root1,Root2
Step6: else if(d<0)
Print ’Imaginary roots’
Step7: Stop


Test Data:

Valid Data Set:
Invalid Data Set:
Limiting Data Sets:








WEEK 3:

Name of the Experiment:

a) AIM: Program to find the factorial of a given number
Software/Hardware Requirements:

S/W: Turbo C, Office XP, Windows NT Server with Service Pack
H/W: Pentium IV, Intel Mother Board Processor, 40 GB HDD,256 MB RAM
ALGORITHM:
Step1: start
Step2: input n,I,f
Step3: f=i=1
Step4: if(i<=n)
Step5: f=f*i
Step6: i=i+1
Step7: repeat from step5 to step6 till steps true
Step8: print f
tep9: stop


Test Data:

Valid Data Set:
Invalid Data Set:
Limiting Data Sets:

Name of the Experiment:


b) AIM: Write C programs that use both recursive and non-recursive functions
To find the GCD (greatest common divisor) of two given integers

ALGORITHM:

Step1: Start
Step2: read a,b
Step3: if(n>m)
rem=p-(p/q*q)
if(rem==0)
return q
else
rem=q-(q/rem*rem)
repeat the step3
Step4: else if(n==0)
return m
Step5: else if
return p-(p/p%q)
Step6: Stop


Test Data:

Valid Data Set:
Invalid Data Set:
Limiting Data Sets:
WEEK 4:

Name of the Experiment:

AIM: Program to perform the arithmetic expression using switch statement
Software/Hardware Requirements:

S/W: Turbo C, Office XP, Windows NT Server with Service Pack
H/W: Pentium IV, Intel Mother Board Processor, 40 GB HDD, 256 MB RAM
ALGORITHM:
Step1:start
Step2:input a,b
Step3:switch(result)
Step4:case ‘+’:print num of a& b is a+b
Step5: case ‘-’:print num of a& b is a-b
Step6: case ‘*’:print num of a& b is a*b
Step7: case ‘/’:print num of a& b is a/b
Step8: case ‘%’:print num of a& b is a%b
Step9: default: invalid option
Step10: stop

C programing-operator

C operators

C Programming - Operators

In this class you will learn about Operators, Arithmetic operators, Relational Operators, Logical Operators, Assignment Operators, Increments and Decrement Operators, Conditional Operators, Bitwise Operators and Special Operators.
Operators Introduction
An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C language program to operate on data and variables. C has a rich set of operators which can be classified as

1. Relational Operators
2. Arithmetic operators
3. Assignment Operators
4. Special Operators
5. Increments and Decrement Operators
6. Conditional Operators
7. Bitwise Operators
8. Logical Operators



1. Arithmetic Operators

All the basic arithmetic operations can be carried out in C. All the operators have almost the same meaning as in other languages. Both unary and binary operations are available in C language. Unary operations operate on a singe operand, therefore the number 5 when operated by unary – will have the value –5.
Arithmetic Operators
Operator Meaning
+ Addition or Unary Plus
– Subtraction or Unary Minus
* Multiplication
/ Division
% Modulus Operator
Examples of arithmetic operators are

x + y
x - y
-x + y
a * b + c
-a * b
etc.,

here a, b, c, x, y are known as operands. The modulus operator is a special operator in C language which evaluates the remainder of the operands after division.


2. Relational Operators

Often it is required to compare the relationship between operands and bring out a decision and program accordingly. This is when the relational operator come into picture. C supports the following relational operators.
Operator Meaning
<> is greater than
>= is greater than or equal to
== is equal to
!= is not equal to
h
It is required to compare the marks of 2 students, salary of 2 persons, we can compare them using relational operators.

A simple relational expression contains only one relational operator and takes the following form.

exp1 relational operator exp2

Where exp1 and exp2 are expressions, which may be simple constants, variables or combination of them. Given below is a list of examples of relational expressions and evaluated values.

6.5 <= 25 TRUE -65 > 0 FALSE
10 <> b && x = = 10

The expression to the left is a > b and that on the right is x == 10 the whole expression is true only if both expressions are true i.e., if a is greater than b and x is equal to 10.

3. Assignment Operators

The Assignment Operator evaluates an expression on the right of the expression and substitutes it to the value or variable on the left of the expression.

Example

x = a + b

Here the value of a + b is evaluated and substituted to the variable x.

In addition, C has a set of shorthand assignment operators of the form.

var oper = exp;

Here var is a variable, exp is an expression and oper is a C binary arithmetic operator. The operator oper = is known as shorthand assignment operator


Example

x + = 1 is same as x = x + 1

The commonly used shorthand assignment operators are as follows

Shorthand assignment operators



Statement with simple
assignment operator

Statement with
shorthand operator

a = a + 1

a += 1

a = a – 1

a -= 1

a = a * (n+1)

a *= (n+1)

a = a / (n+1)

a /= (n+1)

a = a % b

a %= b


8. Logical Operators

C has the following logical operators, they compare or evaluate logical and relational expressions.


Operator

Meaning

&&

Logical AND

||

Logical OR

!

Logical NOT

Logical AND (&&)

This operator is used to evaluate 2 conditions or expressions with relational operators simultaneously. If both the expressions to the left and to the right of the logical operator is true then the whole compound expression is true.

Example

a > b && x = = 10

The expression to the left is a > b and that on the right is x == 10 the whole expression is true only if both expressions are true i.e., if a is greater than b and x is equal to 10.


Logical OR (||)

The logical OR is used to combine 2 expressions or the condition evaluates to true if any one of the 2 expressions is true.

Example

a <>

The expression evaluates to true if any one of them is true or if both of them are true. It evaluates to true if a is less than either m or n and when a is less than both m and n.

Logical NOT (!)

The logical not operator takes single expression and evaluates to true if the expression is false and evaluates to false if the expression is true. In other words it just reverses the value of the expression.

For example

! (x >= y) the NOT expression evaluates to true only if the value of x is neither greater than or equal to y

4. Increment and Decrement Operators


The increment and decrement operators are one of the unary operators which are very useful in C language. They are extensively used in for and while loops. The syntax of the operators is given below

1. ++ variable name
2. variable name++
3. – –variable name
4. variable name– –

The increment operator ++ adds the value 1 to the current value of operand and the decrement operator – – subtracts the value 1 from the current value of operand. ++variable name and variable name++ mean the same thing when they form statements independently, they behave differently when they are used in expression on the right hand side of an assignment statement.

Consider the following

m = 5;
y = ++m; (prefix)

In this case the value of y and m would be 6

Suppose if we rewrite the above statement as

m = 5;
y = m++; (post fix)

Then the value of y will be 5 and that of m will be 6. A prefix operator first adds 1 to the operand and then the result is assigned to the variable on the left. On the other hand, a postfix operator first assigns the value to the variable on the left and then increments the operand.


5. Conditional or Ternary Operator


The conditional operator consists of 2 symbols the question mark (?) and the colon (:)
The syntax for a ternary operator is as follows

exp1 ? exp2 : exp3

The ternary operator works as follows

exp1 is evaluated first. If the expression is true then exp2 is evaluated & its value becomes the value of the expression. If exp1 is false, exp3 is evaluated and its value becomes the value of the expression. Note that only one of the expression is evaluated.

For example

a = 10;
b = 15;
x = (a > b) ? a : b

Here x will be assigned to the value of b. The condition follows that the expression is false therefore b is assigned to x.




6. Bitwise Operators

C has a distinction of supporting special operators known as bitwise operators for manipulation data at bit level. A bitwise operator operates on each bit of data. Those operators are used for testing, complementing or shifting bits to the right on left. Bitwise operators may not be applied to a float or double.

Operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise Exclusive
<<>> Shift right

7. Special Operators

C supports some special operators of interest such as comma operator, size of operator, pointer operators (& and *) and member selection operators (. and ->). The size of and the comma operators are discussed here.

The Comma Operator(,)
The comma operator can be used to link related expressions together. A comma-linked list of expressions are evaluated left to right and value of right most expression is the value of the combined expression.

For example the statement
value = (x = 10, y = 5, x + y);
First assigns 10 to x and 5 to y and finally assigns 15 to value. Since comma has the lowest precedence in operators the parenthesis is necessary.

Some examples of comma operator are
In for loops:
for (n=1, m=10, n <=m; n++,m++) In while loops While (c=getchar(), c != ‘10’) Exchanging values t = x, x = y, y = t; The size of Operator The operator size of gives the size of the data type or variable in terms of bytes occupied in the memory. The operand may be a variable, a constant or a data type qualifier. Example m = sizeof (sum); n = sizeof (long int); k = sizeof (235L); The size of operator is normally used to determine the lengths of arrays and structures when their sizes are not known to the programmer. It is also used to allocate memory space dynamically to variables during the execution of the program.

7. Bitwise Operators

C has a distinction of supporting special operators known as bitwise operators for manipulation data at bit level. A bitwise operator operates on each bit of data. Those operators are used for testing, complementing or shifting bits to the right on left. Bitwise operators may not be applied to a float or double.



Operator

Meaning

&

Bitwise AND

|

Bitwise OR

^

Bitwise Exclusive

<<

Shift left

>>

Shift right

India and Obama - in a nutshell

Indian-American community welcomes Obama as US President

Dharam Shourie New York Leaders of the Indian-American community today welcomed the election of Barack Obama as the next President of the US, expressing confidence that growing ties between the two countries would be further strengthened during his tenure. Chairman of the American Indians for Democrats Sant Singh Chatwal, a major fund-raiser for the party, said Obama along with Vice President Joseph Biden would follow a pragmatic foreign policy as they understand the reality of the global situation.
Biden, he noted, was instrumental in the successful conclusion of the landmark Indo-US Civilian Nuclear Deal. Chatwal, who was among the select leaders invited for the Democratic victory party in Washington, expressed the hope that Obama will be able to bring about real change and his "progressive" ideas would help lift the country's economy and enable the country forge wider alliances to fight terrorism and other such scourges.
Congratulating Obama on his "great victory", the Indian National Overseas Congress (INOC), USA, expressed the hope that the new president would continue to seek strengthening Indo-US relations. In a statement, its General Secretary George Abraham said that both India and the United States have common and pluralistic traditions and need to work together in resolving complex problems facing the world.
"The last few years under the Bush administration has seen ties between US and India grow culminating in the landmark civilian deal," he said, adding that INOC expects the relations to get further boost under Obama

India and Obama - in a nutshell

What Cheers India:
Natural Ally: Obama says building strategic partnership with India top priority and sees India as a natural strategic ally of the US in the 21st century.
Terrorism and Pakistan: More focussed on ending terrorism and Al Qaeda by concentrating on finishing Al Qaeda sanctuaries in Pakistan and bringing stability in Afghanistan. Plans to increase aid to Afghanistan.
Iraq and Muslim world: Promises withdrawal of troops in Iraq within 18 months - a fountainhead of hostility against the US in the Muslim world. Makes it easier for India to deal with a US with better standing in the Middle East.
Economy: Favours greater regulation of financial institutions.
Backs immigration reform and H1B visa programme.
What makes India cautious:
CTBT: Obama has strong views on non-proliferation. May try to force India to accept CTBT (Comprehensive Test Ban Treaty) and provoke a fresh debate in India on this sensitive issue. Shouldn't be a problem after the US, China come on board.
Kashmir: May try to play peace-keeper in Kashmir, a tendency that is likely to be resented and opposed by India which sees Kashmir as a bilateral issue between India and Pakistan and one that does not need third-party intervention.
Outsourcing: India fears global financial meltdown may force Obama to turn protectionist.

C & DS PAPERS

I B.Tech Regular Examinations, May/Jun 2008
C PROGRAMMING AND DATA STRUCTURES
( Common to Civil Engineering, Electrical & Electronic Engineering,
Electronics & Communication Engineering, Computer Science &
Engineering, Chemical Engineering, Electronics & Instrumentation
Engineering, Bio-Medical Engineering, Information Technology, Electronics
& Control Engineering, Computer Science & Systems Engineering,
Electronics & Telematics, Electronics & Computer Engineering,
Aeronautical Engineering, Instrumentation & Control Engineering and
Bio-Technology)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆ ⋆ ⋆ ⋆ ⋆
1. (a) Define Algorithm.
(b) What is the use of flowchart ?
(c) What are the different steps followed in the program development? [3+3+10]
2. (a) Give some important points while using return statement .
(b) Write short notes on scope of a variable. [8+8]
3. Write short notes on pointers. [16]
4. Write a program using structures to display the following information for each
customer name, account number, street, city, old balance, current payment, new
balance, account status. [16]
5. Write a program for indexed sequential file for the employee database for the fol-
lowing operation .
(a) Add Record
(b) Delete Record
(c) Search Record based on the department [16]
6. What do you mean by sorting? Mention the different types of sorting, give some
examples and explain any one indetail. [16]
7. What are the advantages and disadvantages of stack ? Write a program to illustrate
stack operation ? [16]
8. (a) What is a network?
(b) What is a spanning tree?
(c) Define minimal spanning tree .
(d) What are the various traversals in a tree? [16]
⋆ ⋆ ⋆ ⋆ ⋆





Code No: 07A1EC01 Set No. 2
I B.Tech Regular Examinations, May/Jun 2008
C PROGRAMMING AND DATA STRUCTURES
( Common to Civil Engineering, Electrical & Electronic Engineering,
Electronics & Communication Engineering, Computer Science &
Engineering, Chemical Engineering, Electronics & Instrumentation
Engineering, Bio-Medical Engineering, Information Technology, Electronics
& Control Engineering, Computer Science & Systems Engineering,
Electronics & Telematics, Electronics & Computer Engineering,
Aeronautical Engineering, Instrumentation & Control Engineering and
Bio-Technology)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆ ⋆ ⋆ ⋆ ⋆
1. (a) Explain the working of Unary Operator with example.
(b) Explain the working of Binary Operator with example.
(c) Explain the working of assignment Operator with example.
(d) Explain the working of ternary Operator with example. [4+4+4+4]
2. What is the advantage of using functions. Write a ’C’ program to explain about
built in functions with an example. [16]
3. What is the advantage of using arrays ? Give syntax for declaration , accessing
and printing one - dimensional array ? [16]
4. Define Structure and write the general format for declaring and accessing members.
[16]
5. Write a program to read the following data , to find the value of each item and
display the contents of the file . [16]
Item Code Price Quantity
Pen 101 Rs. 20 5
Pencil 103 Rs. 3 100
6. Compare the advantage and disadvantage of bubble, insertion and selection sort.
[16]
7. Define Abstract Data Type . Explain with an example . [16]
8. (a) What is a network?
(b) What is a spanning tree?
(c) Define minimal spanning tree .
(d) What are the various traversals in a tree? [16]
⋆ ⋆ ⋆ ⋆ ⋆






Code No: 07A1EC01 Set No. 3
I B.Tech Regular Examinations, May/Jun 2008
C PROGRAMMING AND DATA STRUCTURES
( Common to Civil Engineering, Electrical & Electronic Engineering,
Electronics & Communication Engineering, Computer Science &
Engineering, Chemical Engineering, Electronics & Instrumentation
Engineering, Bio-Medical Engineering, Information Technology, Electronics
& Control Engineering, Computer Science & Systems Engineering,
Electronics & Telematics, Electronics & Computer Engineering,
Aeronautical Engineering, Instrumentation & Control Engineering and
Bio-Technology)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆ ⋆ ⋆ ⋆ ⋆
1. What are the different types of control statements available ’C’. Explain them with
an example? [16]
2. (a) Write short notes on auto and static storage classes.
(b) Write short notes on call by reference . [8+8]
3. Define an array. What are the different types of arrays. Explain.
[16]
4. Define Structure and write the general format for declaring and accessing members.
[16]
5. What is the purpose of library function feof() ? How feof() be utilized within a
program that updates an unformatted data file. Explain [16]
6. Write a program to sort the elements whose worst and average case are O(n log n).
[16]
7. Give an algorithm / C program to reverse a singly linked circular list inplace. [16]
8. Write an algorithm to perform deletion operation in a Binary Search Tree. [16]
⋆ ⋆ ⋆ ⋆ ⋆


Code No: 07A1EC01 Set No. 4
I B.Tech Regular Examinations, May/Jun 2008
C PROGRAMMING AND DATA STRUCTURES
( Common to Civil Engineering, Electrical & Electronic Engineering,
Electronics & Communication Engineering, Computer Science &
Engineering, Chemical Engineering, Electronics & Instrumentation
Engineering, Bio-Medical Engineering, Information Technology, Electronics
& Control Engineering, Computer Science & Systems Engineering,
Electronics & Telematics, Electronics & Computer Engineering,
Aeronautical Engineering, Instrumentation & Control Engineering and
Bio-Technology)
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
⋆ ⋆ ⋆ ⋆ ⋆
1. (a) Define Algorithm.
(b) What is the use of flowchart ?
(c) What are the different steps followed in the program development? [3+3+10]
2. Write a program to find sum of given series by using function with argument and
return value e = 2 + 3/1! - 6/2! + 9/3! - 12/4! .....! [16]
3. Write a program and explain the working of malloc and calloc function. [16]
4. Define Structure and write the general format for declaring and accessing members.
[16]
5. Describe types of files with an example . [16]
6. Write a program to explain selection sort . Which type of technique does it belong.
[16]
7. What difference between queue and circular queue ? Explain about circular queue
operations ? [16]
8. Explain tree traversals indetail . [16]
⋆ ⋆ ⋆ ⋆ ⋆