2003 University of Mumbai Bombay B E Computer Science COMPUTER PROGRAMMING I JAN 2003 University Question paper for exam preparation. Question paper for 2003 University of Mumbai Bombay B E Computer Science COMPUTER PROGRAMMING I JAN 2003 University Question paper, 2003 University of Mumbai Bombay B E Computer Science COMPUTER PROGRAMMING I JAN 2003 University Question paper. SiteMap

## Exam Preparation

 • AIPMT Exam Preparation • Civil Services Exam Preparation • IIT JEE Exam Preparation • Class 12th Standard Exam Preparation • Class 11th Standard Exam Preparation • Class 10th Standard Exam Preparation • Class 9th Standard Exam Preparation • Class 8th Standard Exam Preparation

## Question Papers

 • Class 9th Standard Question Paper • Class 10th Standard Question Paper • Class 11th Standard Question Paper • Class 12th Standard Question Paper • BA Question Paper • BBM Question Paper • BCA Question Paper • BCom Question Paper • BE Question Paper • BSc Question Paper • BTech Question Paper • LLB Question Paper • LLM Question Paper • MA Question Paper • MBA Question Paper • MCA Question Paper • MCom Question Paper • MSc Question Paper • MTech Question Paper

# 2003 University of Mumbai Bombay B E Computer Science COMPUTER PROGRAMMING I JAN 2003 University Question paper

University Question Papers
2003 University of Mumbai Bombay B E Computer Science COMPUTER PROGRAMMING I JAN 2003 University Question paper
COMPUTER PROGRAMMING - I (JAN. 2003)
Section I
(a) Write a program that, given a number as input, prints its square, cube and fourth power without doing any unnecessary calculations. (3)
(b) Write a program which reads and multiplies together 20 real numbers (floating point numbers). * (3)
(c) Write a program to print a "4 times table" in the following form. (3)
1x4 = 4
2x4 = 8

3x4=12
4x4=16 etc.
(d) Write a program that prints a Christmas tree. (4)

(Use escapes sequence to print the \ and " characters)
(e) Write a program that reads a number greater than or equal to 1,000 from the user where the user enters a comma in the input. Then print the number without a coma. Here is the sample dialog. (5)
Please enter an integer between 1,000 and 999,999: 34,678 34678
(a) Write a program that read two floating point numbers and tests whether they are the same up to two decimal places. (4)
(b) Rewrite the following do loop into awhile loop (4)
int n = 1;
float x = 0; float s;
do
{
S=1.0/(n*n);
x = x + s;
n++;
}
while (s>0.01);
(c) The Fibonacci sequence is defined by the following rule. The first two values in the sequence are 1 and 1. Every subsequent value is the sum of the two values preceding it. Write a program that prompts the user for n and prints the nth value of the Fibonacci sequence. (4)
(d) Factoring of integers. Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 150, the program should print (4)

2
3
5
5
3. (a) Write the program to compute the distance S fallen by an object in free fall:
The formula is S = So + Vot + 1 /2at2.
Make a table of S for t=1,5, 10, 15,20,25……100. (8)
(b) Write a program to input data in to an array X (100), Compute the sum and average. Then count the number of values of X greater than the average and the number less than average. Print the values, The average, and the two counts. (8)
4. (a) One dimensional Array 'A [J]' has N elements and are in the memory of the computer. Write a program segment which
i) Interchanges A[1] and A[2], only if A[1] > A[2], interchanges A[3] and A[4] only if A[3] > A[4] and so on.
ii) Cyclically permutes the values of A so that A[2] contains the original value of A[1], A[3] contains the original value of A[2] and so on, with A[1] containing the original value of A[N]. (8)
(b) Write a program to read the names and total marks of a class of 50 students. Arrange the data (names and marks) in descending order of total marks and print the output with proper headings. (8)
5. (a) List and explain UNIX commands. (8)
(b) Write notes on UNIX Filestore (Files and Directories). (4)
(c) Describe UNIX as an operating System. (4)
Section II
6. Explain the following with suitable programs (18)
(a) Storage classes in C.
(b) Preprocessor directive # define and # include.
(c) Strings and string handling factions in C.
7. A magic square is an n x n array of integers having the same value for the entire row sums, column sums and sums of the two main diagonals. For Example: (16)
4 9 2
3 5 7
8 1 6
In a 3 x 3 magic square with the sum of the rows, columns and diagonals equals to 15. The algorithm for forming an n x n magic square when n is as follows:
(a) Generate the integers from 1 through n2.
(b) As this is done, place the first number in the middle of the bottom row of the array in position A (i, j).
(c) Place the rest of the number in position A (MOD (i, n) + 1, MOD(j,n) + 1}, unless a number is already there. In that case place it in position A(i-I,j).
(d) Repeat above step (step c.) until all the integers have been placed in the array. Write a program that generates and prints magic squares ofsizes3,5,7,9,11, 13,15.
8 With the help of Functions for matrix multiplication and transpose write a program to check the identity ( A X B )T = BT X AT where the order of matrix A is M X L and B is L X N. Also write functions for matrix reading and matrix display. (16)
9. (a) What are recursive functions ? Explain with suitable examples. (8)
(b) Write a recursive function to find the GCD of two numbers using the following Euclid's recursive algorithm. (8)
GCD(m, n) if n > m
GCD (m, n) = m if n = 0
( GCD(n, m%n) otherwise
10.(a) What is a union ? How does a union differ from a structure ? Explain with suitable examples. (4)
(b) What is self referential structure ? For what kind of applications are self referential structures useful? (4)
(c) Write a complete program to iimplement a structure for the following fields. (8)
Name
Roll number
Date of Birth
Total marks
And also provide the provision to sort the list (Array of structures) on
any desired Field e.g. on Name, Roll number, Date of Birth etc.