ALCCS
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 a. What are the different data types available in C? Describe them briefly along with memory requirement.
b. Write a function to check whether a given year is a leap year or not.
c. What is the difference between *ptr++ and ++*ptr?
d. What are formal and actual parameters? Differentiate between them with the help of an example.
e. Write a function to check whether a string is a palindrome or not.
f. Differentiate between entry controlled and exit controlled loops with examples.
g. Write a function to swap two integers without using any temporary variable and any additional space. (7 4)
Q.2 a. Explain preprocessor and directives.
b. Write a non-recursive function int fib(int n) that returns the nth fibonacci number.
c. Why is a linked list called a dynamic data structure? What are the advantages of using linked lists over arrays? (6+6+6)
Q.3 a. What is the difference between an enumeration and a set of processor #defines?
b. A positive integer is entered through the keyboard. Write a function to obtain the prime factors of this number. Modify the function suitably to obtain the prime factors recursively. (8+10)
Q.4 a. Using switch statement write a program to find out the roots of a quadratic equation.
b. Write a program to generate the following output.
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A (9+9)
Q.5 a. Among the functions fgets() and gets() which is safer to use and why?
b. Write a program to check weather a 33 matrix is symmetric or not. (8+10)
Q.6 a. What is the difference between formatted and unformatted console I/O?
b. Given two sorted lists where the first list is sorted in ascending order and the second list is sorted in descending order. Write a program to merge these two sorted list to obtain a sorted list in ascending order. (8+10)
Q.7 Write short notes on (Any THREE):
(i) File Handling.
(ii) Principles of documentation.
(iii) Passing an array as an argument.
(iv) Binary Search. (6+6+6)