ALCS
FEBRUARY 2009
PROBLEM SOLVING
THROUGH C
NOTE:
· Question 1 is compulsory and
carries 28 marks. Answer any FOUR
questions from the rest. Marks are
indicated against each question.
· Parts of a question should be
answered at the same place.
Q.1 (7
x 4)
a. Describe briefly the Top Down
and Bottom-up approach of Problem Solving and programming.
b. Write a code to add two
numbers without using “+” operator.
c. Predict the output of the following function:
main()
{
char *p;
printf ("%d %d
",sizeof(*p),sizeof(p));
}
d. What is the difference between char *a and
char a[ ] ?
e. Differentiate
between declaration and definition of a function with the help of an example.
f. What
are bit fields? What is the use of bit
fields in structure declaration?
g.
In
what ways does a switch statement differ from an if statement.
Q.2 a. What is the purpose of malloc() ,
calloc(), realloc() and free()? (8)
b. Write
a program to reverse each word of the string.
Input string: “ram is a good
boy”
Output string: “mar si a doog
yob”. (10)
Q.3 a. Write
a program to count the number of occurrences of any two vowels in succession in
a line of text. For example, in the
following sentence:
“Please
read the application and give me loan”
Such
occurrences are ea, ea, io, oa i.e. 4 occurrences. (10)
b. Write a function power (a, b), to calculate the value of a raised to power
b, where b is an integer. (8)
Q.4 a. Write a string compare function (Apart from strcmp () ). (6)
b. Develop an algorithm to check whether given input number n is prime or not. (8)
c. Ten
floats are to be stored in a memory.
What would be preferred, an array or a structure? Justify. (4)
Q.5 a. Define preprocessor and directives. Give examples of directives used to
control Preprocessors. (8)
b. Write a function to calculate sum of the digits of the 5 digit positive
number:
(i) without using recursion.
(ii)
using recursion. (10)
Q.6 a. Write
a program to pick up the largest number from any 5 row by 5 column matrix. (8)
b. Write a function to print all of the
permutations of a string. For example if input is ABC, output should be
ABC, ACB,
BAC, BCA, CAB, CBA. (10)
Q.7 a. Write short notes on (Any THREE):
i.
Linkers and loaders.
ii.
Structure and
iii.
Black Box Testing.
iv.
File handling in C.
(6+6+6)