Вы находитесь на странице: 1из 21

www.techbirbal.

com

(COMPUTER PROGRAMMING - I) (JUNE 2002)

N. B.:

(1) Attempt any three questions from each section including Question Nos. 1 and
6 which are compulsory questions.

(2) Answers each section on separate answer-books.

(3) Assume suitable data but justify it.

(4) Use comments in programme and draw the flow-chart for each programme.
Logical correctness of the programme is must, syntax of the C-language must be
followed.

(5) Figures to the right indicate full marks.

(6) Use appropriate variable names in writing C-Programme.

Section I

1. Answer any six - (18)

(a) Define the Top-Down Program development method in C-Programming. (state


5-step)

(b) Explain any three Bitwise operators with suitable examples.

(c) Comment of the following expression in C with suitable examples. EXP1?


EXP2? EXP3?

(d) Comment with suitable examples on the following operators in C in pointers &
and * .

(e) Explain any three backspace characters in C with suitable examples.

(f) State true or false any three:

i) x=15, y=10

x> = 8&y< = x

ii) 10 = 9 + 1;

iii) for(x = 0; x<1000; x++);

{print f (" Jai Hind \ n");}

iv) null character = \ n.

(g) Comment in one line any three:


www.techbirbal.com – Engineering the Future
www.techbirbal.com

i)% x. ii)% o iii)% e iv)\f

(h) Give Range and Byte-width for following Data types in C any three :

i) longint- ii) float- iii) char- iv) double- v) shortint-

(i) Comment on with suitable examples any three :

i) % ii) / iii) ++ iv) --

(j) State differences in gets () and put () string functions.

2. (a) Write the C-Program to reverse the input 4-digit number. Draw the flow
chart. (Input number is integer type data type in C).(8)

(b) Modify the above C-Program to separate the individual digital 4-digit number
and display. Also get the sum of separated digits of same 4-digit number.

( Input No. 1234. Out put No. = 4321. separated digits 1, 2, 3, 4. sum = 4 + 3 + 2+
1- 10). (8)

3. (a} Explain any four string-Library functions in C, with suitable examples.(4)

(b) Write a G-Program with functions. (8)

del-char () & add-char () for the user-input string.

* del-char () - functions take 3-arguments.

i) Original IIP string.

ii) No of characters to be deleted.

iii) Starting positions in the string where characters should be deleted.

* add-char () - function takes 3-arguments

i) String to be added.

ii) Original string.

iii) Starting position where string is to be added.

(c) Explain the following operators in C with suitable examples.

Any Four: (4)

i) || iv) !

www.techbirbal.com – Engineering the Future


www.techbirbal.com

ii) == v) &&

iii) ! =

4. (a) Explain the UNIX directory structure with suitable example. (4)

(b) Write the C-program to select 8s to display and to count total No of vowels
contained in User-Input string. (UseVowels(--)asfunction).Giveflow-chartalso. (8)

(c) Explain the variables in C for the following types, with suitable examples-
(4) i) extern modifier for variables. ii) static modifier for variables.

5. (a) Answer in short-

i) Show the use of > and > > redirection operators in UNIX. (4)

ii) Draw and LabeL UNIX OS Architecture diagram.

(b) Write the C-Program to display (EVEN) or [ ODD ] words for the input of
integer no. Using C-library functions. Draw the flow chart also. (8)

(c) Answer in short-

Compare the switch ( ) control. Statement with ladder. Control statement if-else-if.
(4)

Section II

6. Answer any six:- (18)

(a) Explain the cast operators of C-Programming Language with suitable


examples.

(b) Explain following statements any three -

i) Break; ii) exit; iii) continue; iv) goto stop;

(c) Let char x=7;

evaluate the following operations.

x<<1

x<<3

x<<2

x<<1

x<<2

www.techbirbal.com – Engineering the Future


www.techbirbal.com

Give every step and final output.

(d) Explain the arg C and arg V arguments of main ( ) function with suitable
examples.

(e) Give the format control words of-printf (- -) function.

(f) Give the format control words of-scanf (- -) function.

(g) Explain the following functions -

i) atoi(P). ii) main( ). iii) getchar( )andputchar( ).

(h) Explain the typedef-statement with suitable examples.

i) Define the structure for the following examples, any one: i) Computer ii)
Teacher iii) Student.

7. (a) Explain and compare the while & do-while control loops of C language
with suitable examples. (8)

(b) Write commands at UNIX prompt $ for the following.

Answer any four:

i) delete my file. ii) copymy file.

iii) move my file. iv) list processes which are running

v) display Date & Time.

(c) Explain the following with suitable example: (4)

i) single indirections in pointers.

ii) multiple indirections in pointers.

8. (a) Write the menu driver program in C to perform the Trignometric


functional calculator for the following functions - (8)

S sin (x)

C cos (x)

T Tan (x)

X exit to DOS. (Use switch & library functions).

(b) Explain the following terms in C.

i) malloc( ) iv) General form of functions.


www.techbirbal.com – Engineering the Future
www.techbirbal.com

ii) free ( ) v) declaration in C.

iii) nested for Loop.

Give suitable examples for each case.

9. (a) Explain the following with suitable examples- (12)

i) call by value. iii) pointers to functions,

ii) call by reference.

(b) Explain the following terms any two:- (4)

i) Enumerated data types,

ii) # define constants, operators, macros,

iii) C-short Hard statements for - *, /, %, - operators.

10. (a) Write the C-program to declare the structure for. COMPUTER configuration
having CPU-type, SDRAM-size, clock-speed, HDD-size, CDROM-Type (ROM, R/w),
CDROM-speed, Mouse-Type, Key-Board-Type, SVGA monitor make.

Read in the information for 50 COMPUTERS and list COMPUTER moving HDD-size
greater than 8GB. (8)

(b) Explain the following library functions: (8)

i) strcat(sl,s2). ii) strchr(sl.char).

iii) isaplha (char). iv) isdigit(char).

v) strcmp(sl, s2). vi) strcpy(sl, s2).

vii) srtlen(sl). viii) islower(char).

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)

www.techbirbal.com – Engineering the Future


www.techbirbal.com

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

www.techbirbal.com – Engineering the Future


www.techbirbal.com

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)

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)

www.techbirbal.com – Engineering the Future


www.techbirbal.com

(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)

492

357

816

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)
www.techbirbal.com – Engineering the Future
www.techbirbal.com

(b) What is self referential structure ? For what kind of applications are self
referential structures useful? (4)

(c) Write a complete program to implement 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.

COMPUTER PROGRAMMING - I (JUNE 2003)

N.B.:

(1) Question Nos. 1 and 6 are compulsory.

(2) Attempt any three questions from each section.

Section I

1. (a) Explain basic data types supported by C-language along with their format
specifiers, memory requirements and Ranges. Give suitable example. (8)

(b) What are the identifiers ? State whether the following identifiers are valid or
not. (4) i) oabb ii) a_bc iii) *xyz iv) abcl23

(c) Explain any three escape sequence characters with suitable example. (3)

(d) Explain any three bit-wise operators with suitable example. (3)

2. (a) Write a program to generate Fibonacci series (1, 1, 2, 3, 5……..) for n no.
of terms with flowchart. (8)

www.techbirbal.com – Engineering the Future


www.techbirbal.com

(b) Write a C program to check whether the given two floating point nos are same
upto 2 decimal places. (8)

3. (a) Write a program to check whether a given string is palindrome or not with
flowchart. (10)

(b) If x, y and z are integer variables then evaluate the following expressions and
give the final values of x, y and z.

x= 10, y=6, z=8.

i) x = =y + zii) x--+y-- + --z/(x*x) iii) --x + y--*--z. (6)

4. (a) Write a C program to remove extra blank spaces. (8)

Ex: i/p Hello # # world

o/p: Hello # world .

# -blankspace.

|b) Give differences for the following: (8)

i) if_else and switch,

ii) while loop and do while loop. Give suitable examples.

5. (a) Explain following with suitable example:

i) break ii) continue iii) goto (6)

(b) Write a 'C prog, to display and cont no. of vowels in a given string with
flowchart. (8)

(c) State True of False:

i) 'C language is case-sensitive

ii) i = 0;

for(i = 0; i<2; i++);

{printf ("hello");} Above code will print "hello"

Section II

6. (a) Comment on following expression in C with suitable example.

exp 1 ? exp 2: exp 3 (2)

(b) Explain different preprocessor directives with example. (8)


www.techbirbal.com – Engineering the Future
www.techbirbal.com

(c) Explain unix directory structure with example. (4)

(d) Show the use of > and >> redirection operators in unix. (4)

7. (a) Explain different types of storage classes with example. (8) (b)
Explain recursion using example. (8)

8. (a) Explain the following with suitable example: (6)

i) call by value ii) call by reference.

(b) Write a menu driven C prog, to perform following operations on matrices:

i) Addition ii) Subtraction iii) Transpose iv) Multiplication.

Give user defined function for each of the above operation. (10)

9. (a) Write unix commands for the following:

i) To display files and directories

ii) To change the prompt

iii) To delete my life

iv) To display no. of characters in my life.

(b) Explain any three string library functions. (3)

(c) Explain the difference between structure and union.(3)

(d) Write a 'C’ Prog to declare a structure for employee record having name,
employee code and salary. Read in the information for 30 employee and list
employee and list employees having salary greater than 10,000. (6)

10. Determine the O/P of following program segments. (16)

(a) main( ) .

inta,b,*P1,*P2,x,y;

a=12; b = 4; P1=&a; P2 = &b;

x = *P1 * *P2-6;

*P1=*P1+*P2;

www.techbirbal.com – Engineering the Future


www.techbirbal.com

y=(*P1/P2)+10;

Printf("% d % d", *P1,*P2);

Printf("% d % d", a,b);

Printf("%.d % d", x,y);

(b) main( )

intx=10, y=20, P, g;

P=Prod(x,y) g= Prod(p, Prod (x, 2));

Printf("% d % d", p,g);

} int Prod (a, b) int a, b; {return (a *b);}

(c) main ( )

int m = 5; for(;m! = 100;)

Printf("% d",m);

Printf (" ");

m = m + 5;

(d) main ( )

charx=7;

x<< 1;

Printf("% d", x);

Printf (\n % d", x<<3);

www.techbirbal.com – Engineering the Future


www.techbirbal.com

Printf ("\n % d", x<<2);

Printf("\n % d", x>>l);

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 f\y);

printf("% -7.2f",y);

printf("% 10.2e",y);

printf("% 11.4e", -y);


www.techbirbal.com – Engineering the Future
www.techbirbal.com

(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)

www.techbirbal.com – Engineering the Future


www.techbirbal.com

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 ;
www.techbirbal.com – Engineering the Future
www.techbirbal.com

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.

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).

www.techbirbal.com – Engineering the Future


www.techbirbal.com

(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)

www.techbirbal.com – Engineering the Future


www.techbirbal.com

(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) Av) (*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)

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.


www.techbirbal.com – Engineering the Future
www.techbirbal.com

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


www.techbirbal.com – Engineering the Future
www.techbirbal.com

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 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.

www.techbirbal.com – Engineering the Future


www.techbirbal.com

(d) Explain the following with suitable example - (4) i) Break ii)
Continue.

www.techbirbal.com – Engineering the Future

Вам также может понравиться