2005 Mumbai University B.E Computer Science COMPUTER PROGRAMMING - I (JUNE 2005) Question paper
Course: B.E Computer Science University: Mumbai University
COMPUTER PROGRAMMING - I (JUNE 2005)
(a) Write commands at UNIX prompt$ for the following:- (6)
i) To rename a file in working directory.
ii) To change current'$' prompt to '#' prompt.
iii) To sort the contents of a file in reverse order.
iv) To display date and time.
v) To print information about active processes.
vi) To change individual file ownership.
(b) What will be the output of the following program? (4)
main ()
{ int x=5,y,z; ,
z = y = x;
y- = --x;
z- = x --;
x-=--x-x--;
Printf(*y = %d z = %d x = %d", y, z, x); }
(c)
Write a function to find factorial of a number. WAP to find value of BIO using this function, where BIO is defined as - (10)
BIO =n! / r! * (n - r)! , n a natural number and r is also a natural number.
2. (a) WAP using recursive function for finding the value of y wherey = xn, x and y are real numbers and 'n' is a natural number. (10)
(b) WAP to find the largest and the second largest elements in the list entered by the user. (10)
3. (a) What is an Union ? How does it differ from a structure ? Explain with suitable example. (5)
(b) Comment with suitable examples on the following operators used in printers in C:- i) & ii) *. (5)
(c) WAP to input data into an array. Compute the sum and average. Then count the number of valves of the array greater than average and the number of valves less than the average. Print the values, the average and the average and the two counts. (10)
4. (a) Write a recursive function to find the GCD of two numbers using following recursive algorithm: - (10)
GCD (q, p); if q > p
GCD(p, q) = p if q = o
GCD (q, p % q); otherwise
(b) Define a structure called cricket the will describe the following information -
i) Player's name, ii) Country name, iii) Batting average.
WAP that will store information of 100 players using this structure, also arrange and display names of these players in descending order with respect to batting average. (10)
5. (a) WAP to concatenate two strings entered by the user. (5)
(b) Explain various storage classes in 'C. (10)
(c) WAP to count and to display total number of vowels contained in user input string. (5)
6. (a) The following set of numbers is known as Pascal's triangle: -
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
If we denote rows by i and columns by j then any element except the
boundary elements is given by: Pij = P (i - 1) (j- 1) + P(i- 1)j (10)
(b) Given a number, WAP using while loop to reverse the digits of the number, e.g. if number is 3 1 2 4 1 then output will be 1 4 2 1 3. (10)
(a) Explain bit wise operators in C. (6)
(b) Explain for, while and do-while in details. (6)
(c) Explain the following with suitable example - (4)
i) Call by value. ii) Call by address.
(d) Explain the following with suitable example - (4) i) Break ii) Continue.
*****************************************************************************************
2005 Mumbai University B.E Computer Science COMPUTER PROGRAMMING - I (JAN. 2005) Question paper
Course: B.E Computer Science University: Mumbai University
COMPUTER PROGRAMMING - I (JAN. 2005)
N. B.:
(1) Question No. 1 is compulsory.
(2) Attempt any four question out of remaining six questions.
(3) WAP means write a program in 'C language.
1. (a) WAP to find GCD and LCM for two natural numbers entered by user. (5)
(b) Explain bitwise operators in C. (5).
(c) WAP to find the octal equivalent of the natural number entered by the user. (5)
(d) Write commands at UNIX prompt $ for the following: (5) i) To change the individual file ownership.
ii) To search for a pattern in a file.
iii) To display the names of users currently logged on to the system.
iv) To count number of words, lines and characters in a file.
v) To rename a file in working directory.
2. (a) Explain for, while and do-while in details. (8)
(b) WAP to find the largest and the second largest elements in the list entered by the user. (8)
(c) Explain the following functions : (4) (i) Ceil () (ii) sqrt () (iii) fmod () (iv) strcpy ()
3. (a) Explain switch case statement in details. (4)
(b) Design a structure "st" to contain name, date of birth and total marks obtained. Define the structure "dob" to represent date of birth. WAP to read data for n students in a class and sort them in descending order of total marks. (12)
(c) What are the security rights associated with files and directories in UNIX? (4)
4. (a) WAP which contains the functions to do the following: (16)
i) To read elements of a square matrix.
ii) To display elements of the matrix.
iii) To find the transpose of the matrix, using single matrix.
iv) To check whether matrix is symmetric or not. A matrix is
symmetric if its transpose equals to matrix itself. v) To find sum of all the elements lying above the main diagonal.
(b) What is the difference between structure and union? (4)
5. (a) WAP using recursive function for finding the value of y where y = x", x
and y are real numbers and n is a natural number. (8)
(b) A program consists of the following declaration int
A[5] = { 10, 40, 60, 75, 85 ):-' (6)
Assume that starting memory address of "A" is 3ABC : 1 DEZ. What
is the meaning of: -
i) sizeof (A) iv) *(A + 2)
ii) A v) (*A+-2)
iii) *A vi) (A+ 2)
(c) Explain the following functions: (6)
(i) malloc () (ii) calloc () (iii) free ()
6. (a) Explain various storage classes in C. (8)
(b) WAP that deletes the duplicates in the set of numbers entered by the user and prints the list without duplicates.
For ex.list{11, 10,20,5, 11,10} out of { 11,10,20, 5} (8)
(c) Explain the following with suitable example: (4)
(i) Call by value, (ii) Call by address.
7. (a) WAP to read two natural numbers r1 and r2, where r2 is greater than r1, and to generate all the prime numbers between r1 and r2 both inclusive. (8)
(b) Write a function to find factorial of a number. WAP to find value of BIO using this function, where BIO is defined as - (8)
BIO =n! / r! * (n - r)! , n a natural number and r is also a natural number.
(c) WAP to concatenate two stings entered by the user. (4)
**************************************************************************************
2004 Mumbai University B.E Computer Science COMPUTER PROGRAMMING - I (JUNE. 2004) Question paper
Course: B.E Computer Science University: Mumbai University
COMPUTER PROGRAMMING -I (JUNE 2004)
N. B.:
(1) Question Nos. 1 is compulsory.
(2) Attempt any four questions, out of remaining six questions.
Section I
1. i) What are the security rights associated with files and directories in UNIX ? (3)
ii) Write range of long signed int, double and unsigned char. (3)
iii) Explain any three bitwise operators in C. (3)
iv) Explain four types of files in UNIX. (3)
w) What is modular programming ? What are the characteristics and advantages of modular programming ? (3)
vi) What will be the output of following program :- (5)
main ( )
{
floaty =24.5874;
printf("% 7.4f",y);
printf("% 7.2 fy);
printf("% -7.2f",y);
printf("% 10.2e",y);
printf("% 11.4e", -y);
}
(a) Write commands at UNIX prompt $ for the following: (any six):- (6)
i) To print information about active process.
ii) To search for a pattern in a file.
iii) To sort the contents of a file in reverse order.
iv) To change current '$' prompt to '#' prompt.
v) To display date and time.
vi) Tomove'yourfile".
vii) To, list the processes which are running.
(b) i) What is recursive function? Explain with suitable examples. (7)
ii) Write a recursive function ? 'Rev' to reverse a number entered by the user. (7)
(a) The following set of numbers is popularly known as 'Pascal's triangle. (10)
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
If we denote rows by i and columns by j , then any element (except the boundary elements) in the triangle is given by - Pij =Pi-1,j-1 +Pi-1 , j
Write a program to calculate the elements of the Pascal triangle of 06 ' rows and print the results.
(b) i) A square matrix that is, one having the same number of rows and columns, is called a diagonal matrix if its only non-zero elements are on the diagonal from upper left to lower right. Write a program that reads a matrix and checks if it is diagonal matrix. (5)
ii) Write a program to find GCD and LCM for two numbers entered by user. (5)
4.(a) i) Explain different operators in C. Also explain precedence and associativity of operators. (8)
ii) Write the C Program to count and to display total no of vowels contained in user input string. (8)
5. (a) Explain different storage classes in C. (8)
(b) What will be the output of following programs? (12)
i) main ( ) iii) main ( )
{ intx- 10,y,z; {floata = 0.5, b = 0.9 ;
z=y=x; if(a&&b>0.9)
y- = x--; printf("IFPART");
x- = --x-x--; printf(" ELSE PART");
printf("y=%dz=%dx=%d"y,z,) }
}
ii) main ( ) . iv) main ( )
{ inta = b=c = d = e = 40; . { inti = 0;
printf("%d%d%d%d%d">a,b>c,d,e); for (; i < 100; i ++);
} printf ("This will printf hello 100 times")
}
6. (a) What will be the output of following program ?
main ( )
{
staticinta[] = {0, 1,2,3,4};
static int *p [ ] = {a, a + 1, a + 2, a + 3, a + 4};
int * * ptr = p ;
printf("%d%d",a,**p); .
printf (" % d % d", p, * ptr);
}
(b) Explain the followingwith suitable example (any four):- (16)
i) Call by value ii) Break and continue
iii) Preprocessor directives. iv) Call by address
v) Enumerated data types
7. (a) Define a structure called cricket that will describe the following information:- (10)
Player name Team name Batting average
using cricket", declare an array player with 50 elements and write a program to read the information about all 50 players. Sort the structure on there batting average and print the results.
(b) (i) Explain following library functions :- (5)
i) getche ( ) iii) isalnum ( )
ii) puts ( ) iv) toupper ( )
v) stcmp(S1,S2).
(ii) What is a union ? How does a union differ from a structure ? Explain with suitable example.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment