PROGRAMMING AND DATA STRUCTURES

2010 Jawaharlal Nehru Technological University, Hyderabad SET-4 Code.No: 09A1EC01 JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD I B.TECH - REGULAR EXAMINATIONS, JUNE - 2010 C PROGRAMMING AND DATA STRUCTURES Question paper

SET-4
Code.No: 09A1EC01
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
I B.TECH - REGULAR EXAMINATIONS, JUNE - 2010
C PROGRAMMING AND DATA STRUCTURES
(COMMON TO CE, EEE, ME, ECE, CSE, CHEM, EIE, BME, IT, MECT, E.COMP.E, MMT, MEP, AE, ICE, BT, AME)
Time: 3hours Max.Marks:75
Answer any FIVE questions
All questions carry equal marks
- - - - - - -
1.a) List and explain the functions of various parts of computer hardware.
b) A university gives grades based on the percentage of marks obtained in the examinations as follows:
Percentage of marks Grade
70 and above Distinction
60 and above but below 70 First
50 and above but below 60 Second
40 and above but below 50 Third
below 40 Fail
Write a flowchart that inputs the percentage marks and output the division. [6+9]
2.a) Write minimal C- expressions for the following:
i) 6a4 +3a3-5a2-6a+22
ii) 1235abbc+
iii) Equivalent to C-statement while (a > = b)a = a-b where a and b are unsigned integers.
iv) True if x/y >3 without zero divide, false otherwise
v) If xvi) Fourth bit from the right if the number x is treated in binary representation.
b) What is the difference between the following C-words?
i) count and int ii) 526 and "526"
c) Write C-program that reverses the decimal digits of integer value at input. For example, for input 5379, the program need to output 9735. [6+2+7]
3.a) Consider the following recursive function
void toh( int n, char src, char dist, char inter)
{
if (n>0)
{
toh(n-1, src, inter, dist);
printf("move %d from %s to %s\n", n, src,dist);
toh(n-1,inter,dist,src);
}
}
What is the output printed by the above program for the function call toh (4,'A','B','C')?
b) Write C-function float max(float a[], int n) that returns the maximum value of the first n positions of array a. [8+7]
4.a) Consider the following C-program segment.
int x[4][4]={{1,2,3,5},{4,5,6,8},{7,8,9,10}};
int **a=x;
int **b=a++;
what are values of the following C-expressions? Justify your answer.
i) **a ii)*(*(a+1)) iii) *(*a+1)+2)
iv)**b+5 v)*(*(b+1)+1)+1 vi)**(a+2)+7
b) Write C-function void insert (char a[], char c, int *n, int i) that inserts character c at index i in the array by shifting all elements above that position by 1 and incrementing n. [6+9]
5. Write C-structures for departmental store application. Each departmental store contains departmental store Id (3 characters), store location (dynamically allocated string), items (dynamically allocated structures) and number of items. A store can offer 1 to 1000 items. Each Item contains Item code (4 characters), current stock, unit of measure in the following set (Single, dozen, kilogram, liter, meter, square meter) and price. Using this structure, Write C- function to count the number of items whose price is above the given amount. [15]
6.a) Differentiate between fprintf and fwrite statements. When do you prefer to use fwrite instead of fprintf ?
b) Given filename, index and value, Write C-program that reads element of binary files of long integer array at the given index, add value to it and store back at that location. [7+8]
7.a) Write algorithm/Program for binary search to find the given element within array. For What data binary search is not applicable?
b) Show the quick sort results for each exchange for the following initial array of elements
35 54 12 18 23 15 45 38 [7+8]
8.a) Using recursive function for factorial, explain the execution of the function call factorial(5) using stack.
b) Write C-structure for implementing Stack using an array. Using this structure, write functions for push and pop operations. [7+8]
KEYWORDS:PROGRAMMING AND DATA STRUCTURES,PROGRAMMING AND DATA STRUCTURES QUESTION PAPER,JNTU,JNTU QUESTION PAPER,JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD REGULAR EXAMINATIONS JUNE PROGRAMMING AND DATA STRUCTURES