0% found this document useful (0 votes)
121 views25 pages

Problem Solving in C Programming Exam

This document contains sample questions from a MCA degree examination in Problem Solving and Programming. It is divided into three parts - Part A contains 10 multiple choice questions worth 2 marks each, Part B contains 5 questions worth 13 marks each, and Part C contains 1 question worth 15 marks. The questions test concepts like algorithms, program verification, control structures, functions, pointers, files, and data structures in C programming.

Uploaded by

Alia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views25 pages

Problem Solving in C Programming Exam

This document contains sample questions from a MCA degree examination in Problem Solving and Programming. It is divided into three parts - Part A contains 10 multiple choice questions worth 2 marks each, Part B contains 5 questions worth 13 marks each, and Part C contains 1 question worth 15 marks. The questions test concepts like algorithms, program verification, control structures, functions, pointers, files, and data structures in C programming.

Uploaded by

Alia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Reg. No.

Question Paper Code : J1353

M.C.A. DEGREE EXAMINATION, FEBRUARY/MARCH 2018.

First Semester

DMC 7102 — PROBLEM SOLVING AND PROGRAMMING

(Regulations 2013)

Time : Three hours Maximum : 100 marks

Answer ALL questions.

PART A — (10  2 = 20 marks)

1. Distinguish program and algorithm.

2. What is program verification?

3. List the arithmetic operators in C.

4. What is a pseudo code?

5. List the various scope rules.

6. Differentiate recursion vs. iteration.

7. Which operators are related with pointers?

8. Write the purpose of size of operator in pointers.

9. Differentiate struct and union.

10. What is # and ##?

PART B — (5  13 = 65 marks)

11. (a) Analyze the Recursive Quick Sort algorithm and find the time
complexity. (13)

Or
(b) Explain top down design in problem solving with an example. (13)
12. (a) (i) Show the different if control statements with an example for each.
(6)
(ii) Write a C program to calculate the incentive amount of a sales
person based on their annual sales amount
0 to 10,000 – 10% of sales amount
1,000 to 20,000 – 20% of sales amount
2,000 to 30,000 – 25% of sales amount. (7)

Or
(b) (i) What is multiple selection switch statement? Write its syntax. (4)
(ii) Write a C program to compute the EMI amount for a customer’s
purchase on loan using switch control statement.
Number of years EMI
1 10% of loan
2 11% of loan
3 12% of loan
4 14% of loan
5 15% of loan. (9)

13. (a) (i) Explain counter controlled repetition with while loop. Give an
example. (9)
(ii) What is the purpose of header files? Give examples. (4)

Or
(b) (i) What is sentinel controlled repetition? Give example. (4)
(ii) What is an array? Write a program to compute Mean and Median
using arrays. (9)

14. (a) (i) How arguments are passed to a function using references? (10)
(ii) What is array of pointers? Give an example. (3)

Or
(b) What are the string handling functions available in C? Write user
defined functions for string copy, string compare and substring. (13)

15. (a) How formatting input is done in scanf( ) statements? Give an example for
each. (13)

Or
(b) Write a program in C to reverse the contents of a file using random
access file mode. (13)

2 J1353
PART C — (1  15 = 15 marks)

16. (a) Write a C program to find the minimum number in a list of 'N' numbers.
Analyse its time complexity.

Or

(b) Write a C program to check whether all the elements in a given away of
'n' elements are distinct.

——————————

3 J1353
Reg. No. :

Question Paper Code : BS2353

M.C.A. DEGREE EXAMINATION, AUGUST/SEPTEMBER 2017.

First Semester

DMC 7102 — PROBLEM SOLVING AND PROGRAMMING

(Regulations 2013)

Time : Three hours Maximum : 100 marks

Answer ALL questions.

PART A — (10  2 = 20 marks)

1. Define modularity.

2. What does program verification refers to?

3. Define the logical operators in C language.

4. Write a C program to accept two numbers compute its sum and print the
result.

5. Illustrate with an example the use of switch statement in C language.

6. Define recursion.

7. What is a pointer? Give example.

8. Define the bitwise operators in C language.

9. State the difference between sequential access file and random access file.

10. Define a macro in C language. Give example.

PART B — (5 × 13 = 65 marks)

11. (a) What is top-down design? Explain with an example. (13)

Or
(b) (i) Explain with an example verification of program segments with
loops. (8)
(ii) Explain worst and average case behavior of an algorithm with an
example. (5)
12. (a) (i) Explain integer constants and real constants in C language with an
example. (6)
(ii) Write a C program that converts the given temperature in
Fahrenheit to Celsius using the following conversion formula.
F  32
C  (3)
1 .8

(iii) Write a C program to accept a number, check whether the number


is a prime number or not and print the result. (4)

Or
(b) (i) Write a C program to print the first ‘N’ Fibonacci numbers. (5)
Note : The Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,.....N
where each number is the sum of the preceding two.
(ii) Write a C program to perform computation of sin (x) as given
below : (8)
3 5 7 9
x x x x
sin x  x     .......... . N terms.
3! 5! 7! 9!

13. (a) (i) Explain entry-controlled loop and exit-controlled loop with an
example. (7)
(ii) What is a function? Explain with an example. (3)
(iii) Write a C program to compute factorial of a given number using
recursion. (3)

Or
(b) (i) Write a C program to store ‘N’ names in an array. (6)
(ii) Write a C program to sort an array of ‘N’ numbers in ascending
order. (7)

14. (a) (i) Write a C program using pointers to find the length of a character
string. (5)
(ii) What is array of pointers? Explain with an example in C language.
(5)
(iii) Explain enumerated types in C language with examples. (3)

Or
(b) Explain structures and unions in C language with an example. (13)

2 BS2353
15. (a) What is a file? Explain with an example the file handling functions. (13)

Or
(b) A file with name DATA contains a series of integer numbers. Write a C
program to read these numbers and then write all odd numbers to a file
called ODD and all even numbers to a file called EVEN. (13)

PART C — (1 × 15 = 15 marks)

16. (a) Write a C program to accept student personal and academic details and
store in it a file. Print students’ mark sheet.

Or
(b) (i) With example explain pointers to function. (10)
(ii) Give an account on predefined symbolic constants. (5)

—————————

3 BS2353

Common questions

Powered by AI

Program verification involves the process of ensuring a program functions as intended for all input cases, confirming its correctness with respect to its specification. It's significant because it helps reduce software errors, improves reliability, and increases confidence in software systems. Verification techniques, such as formal methods, can prove mathematically that a program meets its requirements .

In C, a 'struct' is used to group variables of different types together, with each member having its own memory location, whereas a 'union' allows storing different variables in the same memory location, but only one member can hold a value at any time. For instance, a 'struct' might define a point with separate 'x' and 'y' coordinates, whereas a 'union' could store different data types for a specific memory-efficient application .

Top-down design is a problem-solving approach that starts from the highest level of abstraction and breaks down the system into smaller, more manageable parts or modules. This design facilitates development by allowing focus on individual components, improving manageability, enabling parallel development, and enhancing code reusability and maintainability .

The Recursive Quick Sort algorithm generally has a time complexity of O(n log n) on average due to its divide-and-conquer nature. However, its worst-case time complexity is O(n^2), which occurs when the smallest or largest element is always chosen as the pivot, leading to unbalanced partitions. Optimizations like choosing a median as the pivot can help mitigate this .

Header files in C define interfaces for reusable code components through declarations of functions, macros, and types and enable the separation of function declarations from implementation, promoting code modularity and reusability. Examples include 'stdio.h' for input/output functions and 'string.h' for string manipulation functions .

An algorithm is a step-by-step procedure or formula for solving a problem, while a program is an implementation of one or more algorithms using a specific programming language. The distinction is important because algorithms are the conceptual foundation, ensuring solutions are generic and not tied to a particular language or system, whereas programs make these concepts operational and executable .

Sequential access files read or write data in a linear fashion, from beginning to end, which is simple and efficient for processing data elements in order. Random access files can read or write data directly at specific positions, offering flexibility to modify data without going through other data, which is advantageous for databases and applications requiring non-linear data manipulation .

'Pointer to functions' enhance modularity and flexibility by allowing functions to be passed as arguments, enabling dynamic invocation of different functions at runtime through a common interface. For instance, using function pointers can facilitate callback mechanisms or enabling strategies like sorting arrays with varying comparison functions .

The 'sizeof' operator in C returns the size, in bytes, of a data type or object, which is crucial in pointer arithmetic for calculating the correct offsets. For example, when using arrays and pointers, it helps determine the number of elements in an array by dividing the total size by the size of an individual element .

Recursion is a method of solving problems where a function calls itself, while iteration uses looping constructs to repeat a set of instructions. Recursion is preferred for problems that can be represented naturally using divide-and-conquer strategies, such as computing factorials or traversing complex data structures like trees. Iteration is generally favored for tasks where performance is critical, as it often uses less memory and can be more efficient .

You might also like