NOTE: There are 11 Questions in all.
· Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space provided for it in the answer book supplied and nowhere else.
· Answer any THREE Questions each from Part I and Part II. Each of these questions carries 14 marks.
· Any required data not explicitly given, may be suitably assumed and stated.
Q.1 Choose the correct or best alternative in the following: (2x8)
a. What is the output of the following program?
main ( )
{ int x = 2, y = 5;
if (x < y) return (x = x+y); else printf (“z1”);
printf(“z2”);
}
(A) z2 (B) z1z2
(C) Compilation error (D) None of these
b. Choose the correct one
(A) Address operator can not be applied to register variables
(B) Address operator can be applied to register variables
(C) Use of register declaration will increase the execution time
(D) None of the above
c. What is the following program doing?
main ()
{ int d = 1;
do
printf(“%d\n”, d++);
while (d < = 9);
(A) Adding 9 integers (B) Adding integers from 1 to 9
(C) Displaying integers from 1 to 9 (D) None of these
d. What is the output of the following program?
main ( )
{ extern int x;
x = 20;
printf(“\n%d”, x);
}
(A) 0 (B) 20
(C) error (D) garbage value
e. If x is one dimensional array, then pick up the correct answer
(A) *(x + i) is same as &x[i] (B) *&x[i] is same as x + i
(C) *(x + i) is same as x[i] +1 (D) *(x + i) is same as *x[i]
f. Consider the following declaration
int a, *b = &a, **c = &b;
The following program fragment
a = 4;
**c = 5;
(A) does not change the value of a (B) assigns address of c to a
(C) assigns the value of b to a (D) assigns 5 to a
g. Choose the correct answer
(A) enum variable can not be assigned new values
(B) enum variable can be compared
(C) enumeration feature increase the power of C
(D) None of the above
h. The content of file will be lost if it is opened in
(A) w mode (B) w+ mode
(C) a mode (D) a+ mode
Answer any THREE Questions. Each question carries 14 marks.
Q.2 a. Write a C program to compute the sum of first n
terms (n
1)
of the following series using ‘for’ loop.
1 – 3 + 5 – 7 + 9 - …… (6)
b. Write a C program to convert a binary number to its corresponding octal number. (8)
Q.3 a. Write a C program to print out n values of the following sequence.
1 –1 1 –1 1 … (6)
b. Write a C program to test whether a given pair of numbers are amicable numbers. (Amicable number are pairs of numbers each of whose divisors add to the other number) (8)
Q.4 a. Write a C program to rearrange the elements of an array so that those originally stored at odd suffixes are placed before those at even suffixes. (6)
b. Admission to a college in science branch is given if the following conditions are satisfied
(i) Maths marks >= 80
(ii) Physics marks >= 75
(iii) Chemistry marks >= 70
(iv) Total percentage in all three subjects >= 80
Given the marks in three subjects, write a program to process the applications to list the eligible candidates. (8)
Q.5 a. Write a C program using while loop to reverse the digits of a given number. (for example, If number is=12345 then output number is= 54321) (5)
b. Write C program to produce 10 rows of the following form of Floyd’s triangle (5)
|
1 |
|
|
|
|
0 |
1 |
|
|
|
1 |
0 |
1 |
|
|
0 |
1 |
0 |
1 |
c. Are the following statements valid? Justify your answer
(i) k = (char*)& m
(ii) m= (float*)& p (4)
Q.6 a. Consider the following macro definition
#define root (a, b) sqrt((a) * (a) + (b) * (b))
What will be the result of the following macro call statement
root(a++, b++) if a = 3 and b = 4 (3)
b. Write a nested macro that gives the minimum of three values. (3)
c. Given are two one dimensional arrays A and B which are stored in ascending order. Write a program to merge them into a single sorted array C that contains every element of A and B in ascending order. (8)
Answer any THREE Questions. Each question carries 14 marks.
Q.7 a. Write a C program that reads the text and counts all occurrences of a particular word. (6)
b. Write a C program that reads a string from keyboard and determines whether the string is palindrome or not. (A string is palindrome if it is read from left or right gives you the same string) (8)
Q.8 a. Write a C function strend(s, t), which returns 1 if the string t occurs at the end of the string s, and zero otherwise. (7)
b. Write a function rightrot(x, n) that returns the value of the integer x rotated to the right by n positions. (7)
Q.9 a. Write recursive function in C to obtain nth term of the Fibonacci series. (7)
b. Write C function named ‘fiddle’ that takes two arguments, x and y and changes both values. x is an int while y is a pointer to int (7)
Q.10 a. What is an unsigned integer constant? What is the significance of declaring a constant as unsigned? (4)
b. How are multidimensional arrays defined? Compare with the manner in which one dimensional arrays are defined? (6)
c. Compare the following pairs of statements with respect to their syntax and function:
(i) break and continue.
(ii) goto and break. (4)
Q.11 a. Explain the difference between the following:
(i) Program testing and debugging.
(ii) Top down and bottom up approaches.
(iii) Interpreted and compiled languages. (6)
b. Write a complete C program for reading an employees file containing {emp_number, name, salary, address}. Create an output file containing the names of those employees along with their salary and address whose salary is > 20,000. (8)