## November 25, 2011

### C PROGRAMMING AND DATA STRUCTURES CPDS JNTU previous years question papers 2011

C PROGRAMMING AND DATA STRUCTURES CPDS JNTU previous years question papers 2011

1.a) What is an algorithm? List and explain the properties of algorithm.
b) A utility company charges its customers based on their monthly utilization in terms of units as follows:
Description charge
First 100 units Rs.10 per unit
Next 200 units Rs. 9 per unit
Next 200 units Rs.8 per unit
Next units Rs.7 per unit
Write flowchart that reads monthly units of a customer and output the charge amount. [7+8]

2.a) Write minimal C- expressions for the following:
i) 6b4 +3b3-5b2+6b+15
ii) 2234abccab−−
iii) Increment x and then add to z
iv) Maximum of the values of 3 variables a, b and c
v) True if the value of character variable c is in uppercase, otherwise false
vi) Rightmost octal digit in the value of integer variable x
b) What is the difference between the following C-words?
i) 5 and ‘5’ ii) if and ++
c) Write C-program for generation of multiplication table for the given integer input x. For example, if input is 5, the program need to output
5 X 1 = 5
5 X 2 =10
…..
5 X10 =50 [6+2+7]

3.a) Consider the following recursive function
int bbb(int n,int r)
{
printf(“%d %d\n”,n,r);
if (r==0 || n==r)return 1;
else return bbb(n-1,r)+bbb(n-1,r-1);
}
What output is printed for the function call bbb (4,2)? What does the function do?
b) Write a C-program that reads the given n observations at input and computes average of n observations and find the number of observations above average value. The input is value of n followed by n observations. [8+7]

4.a) Consider the following C- program segment.
char*months={“JANUARY”,”FEBRAURY”,”MARCH”,”APRIL”, ”MAY”,”JUNE”,”JULY”,”AUGUST”,”SEPTEMBER”,”OCTOBER”,”NOVEMB ER”,”DECEMBER”};
char **a= months;
char **b = a++;
i) **a ii) *(*(a+5)+3)
iii) *(a+7) iv) *(*(a+9)+6)==*(*a+11)+7)
v) *(++b) vi) *(b++ +3)
b) Write C-function void exchange (int *x, int *y) that exchange the values pointed by x and y. In addition the function requires counter that count the number of times the function is invoked. [6+9]

5. Write C-structures for line diagram. The Line diagram has the following fields: diagram Name (dynamically allocated string), no of lines, lines(dynamically allocated structure). The line diagram can have 1 to 500 lines. Each line contains two end points, line thickness in pixels and color in the following set (red, black, blue, green, yellow, orange). Each point contains X-coordinate and Y-coordinate in pixels. Using this structure, write a function int countlines (struct line_diagram *l, int c) that returns the number of lines in the given color c. 

6.a) List and explain different format literals available in printf statement.
b) Write C-language program that reads a C-program file and outputs number of lines in the program. [7+8]

7.a) Write an algorithm or C-function for selection sort for sorting an array of integer in ascending order.
b) Demonstrate the selection sort results for each pass for the following initial array of elements.
21 6 3 57 13 9 14 18 2 [7+8]

8.a) Write an algorithm that convert the given infix expression in to post fix. Demonstrate your algorithm using stack for the expression a + b*c
b) Write C-structures for implementing queues using Linked Lists. Using these structures, write C-function for dequeue operation. [7+8]

## Government jobs in india 