How To Exam?

a knowledge trading engine...


West Bengal Institute of Technology (WBIT) 2008-2nd Sem B.Tech Electronics and Communications Engineering Electronics & Comm ( - ) Basic Computation & Principle of Computer Programming (solved) - Ques

Thursday, 18 July 2013 12:55Web



INTRODUCTION TO COMPUTING2008

.    SEMESTER-2

Time: 3 Hours    Full Marks: 70

4. Choose the correct alternatives for any ten of the following :    - 10><1 = 10

(i)    RAM stands for

(a) Readwrite Access Memory    (b) Read Access Memory

(c) Random Access Memory.    (d) None of these.

(ii)    Operatig system is    -    .

(a) application software    (b) system software

(c) both of these    (d) None of these. -

(iii)    ALU is a part of

(a) memory    (b)CPU    (c) input device (d) output device

(iv)    The output of the following code is : for (i = 1 ; 1 < = 5 ; i++)

' < ' . . ' if i%2)

continue;

printf (%3, i);

> : .

(a) 1 2345    (b) 1 3 5    (c) 24    (d) none of these.

(v)    The output of int i = 5 ;

printf (%d %d %d, i, i++,++i) ;    .

; - is . . . - . -    '    '

(a) 5 5 7    (b) 5 6 7    (c) 7 6 5    (d) 7 6 6

(vi)    The output of    .

#define SQ(x) x*x

void main ( )    .....

{- - .... ' .

. int a, b ;

a = 5;    '    .        '

b = - SQ(a + 2) ;

.    printf (%d, b);

} / . .. -;v '    . is .    .    '    ''    

(a) - 49    (b) -17    (c) 7    (d) none of these.

(vii)    Which one of the following is a Bitwise operator?

(a) <    (b)> =    (c)    (d) &&

(viii)    The output of    . fact = 1 ;

for (i = 1 ; i < 5 ; i++) ;

'    fact = fact*i    -

printf (%d, fact);

is.

(a)24    (b)5    (c), infinite Joop (d) none of these.

(ix)    The output of    , void main ()

. C * ' '    -    . '

int arr [6] = {20,25} ;    .

.    printf (%d %d %d, arr [2], arr [3], arr [4]) ;

} ;

. is * '    -    .    '

(a) 0 0 0    (b) 20 25 0    (c) 25 0 0    (d) none of these.

(x)    The purpose of mode r + is to

(a) open for only reading    (b) open for only writing

(c)    open for both reading and writing (d) none of these

(xi)    Pointer is-

(d)    none of these

(xii)    A function may contain    .

(a) one return statement    (b) two return statements

(c) more than two return statements (d) none of these

Ans. (i) c ; (ii) b ; (iii) b ; (iv) c ; (v) d; (vi) c ; (vii) c ; (viii) b ; (ix) a; (x) c ; (xi) a; (xii) c.

   Group-B

(Short Answer Type Questions)    3x5=15

Answer any three questions.

. 2. (a) What are the basic features of an algorithm?    1

(c)    What are the disadvantages of machine language? -    2 Ans. (a) Refer Q. No. 3.(a) of2003.

Ans. (b) Refer Q. No. 3.(b) of2003.    .

Ans. (c) Disadvantages of machine language: All the instructions is represented by 0s and 1 s in the machine language. It is very difficult to read, write and maintain. It is very time consuming.

Programming in machine code has one advantage over programming at other language levelsits execution is vey fast and efficient because the computer can accept the machine code as it is.

The disadvantages is, there is no one standard machine language. The languages are machine-dependent and the programs written in machine language for one computer model will not, in all likehood, run on a different model computer. Although the machine language for a particular

computer is supplied by the manufacturer, few applications programs are written in machine languages.

3.    With a suitable block diagram, briefly explain the major components and theii functions of any conventional computer system.

Ans. Refer to Q. No. 3.(a) of2002.

4.    (a) Write a function power (a, b) to calculate the value of a raised to b.

(b) What will be the output?

void fun (int*i, int*j);

main ( )

. ( . ' . . , ' . int i = 5, j = 2 ; fun (&i, &j); printf (\n%d %d, i, j) ;

} . . . . .. ; void fun (int*i, int*j)    

'    V .. .

*j = *j**j;    2 + 3

Ans. (a) The value a faised to b :

Program :

// By subhabrata Mandal

#    include <stdio.h>    .

#    include <stdlib.h>    .

#    include <math.h>

#    include <conio.h> void main ()

{ ... ; _ . ". int i, n;

double a, b, f, result = 1;    -

printf (\n Enter the value of A and B);; scanf (%/f %/f, &a, &b);

i = (int) b ;    .    ?

f = fabs (b - i) ; i = abs (i) ;

for (n = 1 ; n <= i; n++) result* = a; if (f> 0 && a< 0)

564 -    WBUT SOLVED BOOK    

* -{ printf (\n Floating point error!); getch ( );

' exit|);

else    -

if(x>0) -        , .

result* = exp (f log (x)); if (y < 0)    '

result = 1 /result: printf (\n the result is % g", result); getch ( );    . ,

} .

5.    (a) What is dynamic memory allocation?    1

(b)    Write down the differences between malloc () and calloc ().    2

(c)    Write down the differences between structure and union.    2 Ans. (a) SeeQ.No. 2.(g)of 2006. ,

Ans. (b) See Q. No. 2.(g) of2006.

Ans. (c) SeeQ,No. 4.(a)of2005.

6.    (a) What are the differences between recursion and iteration.    2

(b) Write a recursive function to calculate factorial of anumber. 3

Ans. (a) SeeQ.No. 9.(a)of 2006.    .

Ans.(b) SeeQ.No. 5. of2006.    .

Group-C (Long Answer Type Questions)

Answer any three questions    3x15 = 45

7.    (a) Write down the differences between compiler and interpreter.    2

(b)    What is an operating system? Write down the basic features and operations of an operating system.    5

(c)    Perform the following operations :    4x2 Ans. (a) See Answer Q.No 2.(c) of 2003 and 3.(b) of 2005. .

Ans. (b) Operating system : Operating system is a programs that runs on a computer to run other programs.

For the second part, see answers of the questions 2.(a) of 2002 and 2.(b) of 2003.

Ans. (c)(i) (100110101)2 = (?)8

100 110 101

ITT ' (100110101)2 = (465)g    ,

(536),


= (15E)


10


1


14


WBUT (COMPUTER) QUESTIONS2008 (ii) (536)8 = (?)16    ' - .

101 0111101


= (101011110)2= 0001 0101 1110


5 3 6


2123 -1 2LU -1 2L5 -1 2[_2 -0 1

integer part = 1 1 =0 = 0 =o

H        1

99    M    1

J    M    1

99    M    1


(iii) (23-78)10 = (?)2

(23)I0 = (10111)2 -78 x 2 = 1 -56 - -56x2= 1-12 . 12 * 2 = 0-24 -24 x 2 = 0-48 -48x2 = 0-96 96 x 2 - 1-92 92 x 2 = 1-84 84 x 2= 1-68 68 x 2 = 1*38


(-78)10=(1100011H)2

(23-78),0 = (10111-110001 111)

(iv) (-7)10 - (7)m = (10001)2 - (00111)2

1 s complement of 00111 = 11000, 2s complement = 11001. (10001)2 - (00111)2 = 010001 + 111001 = (001010)2 = (10),0

T

signbit


T '

signbit


- 1

signbit


(a)    Write a C program to find the largest and smallest among a list of n numbers taken as input.    .    5

(b)    Write a C program to check whether a string taken as input is a palindrome or not.    .    5

(e) Write a C program to print the following pattern (till n rows, where n is

taken as input).

1

2 3 2 4 5 4 3 6 7 6 5 4


Ans. (a) See Q. No. 5 (a) of 2003. Am. (b) Palindrome :

Program :

// By Subhabrata Mondai

# include <stdio.h>

#    include <conio.h>

#    include <string.h> void main ( )

{ . int i, s_len ; char str [30];

printf (/n Enter the string): gets (str) ;

_ s_len = strlen (str) - 1 ;

for (i = 0 ; i < = s_len/2 ; i++) if (strfi]! = str [s len - i]) break; if (i > s_len/2)

.    printf (\n The string is Palindrome) ;

else    

pringt (\n The string is not Palindrome); getch ();

Ans. (c)    

\\ By Subhabrata Mandal

#    include <stdio.h>

. # include <conio.h>    .

void main ( )    ,

{ int i, j, ft ;

printf (\n Entier the rows number)

scanf (%d, & n);

. for (i = 1 ; i < = n ; i-H-)

{

for (j = 1 ; j < = n- i; j++) printf (d); for (j = 1 ; j < = 2 x i - 1 ; j++)

   printf (%dJ); .

fr G ~ j - 2 ; j > = i; j--)

printf (%dj) ;    '

printf (\n);    ,

} ' getch ();

}

Another code :

for (i = 1 ; i < = n ; i++)

{ for (j = 1 ; j < = n - i; j++) printf (b);

for (j = 1 ; j < = 2 * i - 1 ; j++) -

printf (%d, j + i - 1 - ((j - l)/i)*(2*(j - 1) ; printf (\n)    

} ' .

9. (a) Explain call by value and cell by reference mechanism for passing arguments into a-function a function call. Write a C function t swap the value of two integer variables passed as arguments. Also write the main function.    6

(b) Define a structure called cricket that will describe the following information : 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 the 50 players and print the name of hte player having highest batting average.    9

Ans. (a) See Q. No. 8.(a), (b) of 2003.

Ans. (b) Program : .

\\ By Subhabrata Mondal    ,    '

#    include <stdio.h>

#    include <conio.h>

#    define size 50

void main ( )    

{ struct cricket { char p name [30], t name [20]; int avg ;

} p[size] ;    .

int i, max = 0 ;

printf (\n Enter the information of % d players, size) ;

for (i = 0 ; i < size ; i++) ,

{ printf (\n Enter % d Players Name, Team Name, Batting Average, i + 1) ; gets (p[i] . p_name); fflush (stdin) gets (p[i] . t_name) ;

fflush (stdin);        .

scanf (%d, & p[i]. avg);    

fflush (stdin);

for (i = 1 ; i < size ; i++) if (p[max]. avg <p[i] . avg) max = i; printf (\n % s has highest batting average % d, p[max], p_ name, p[max] avg) ;    

getch ( );

}. .....

10. (a) Write a C program that will receive a filename and a line of text as command line argnmts and write tte text to the    :    9

(b)    Write down the differences between while and do-while.    3

(c)    What is type casting? What is automatic type conversion?    3

Ans. (a) Program :    .

//By Subhabrata Mandal        

#    include <stdio.h>

#    include <conio.h>

#    include <stdlib.h>    -void main (int argc, char * argv [ ])

{ FILE *fp; int i;

if (argc < 3)    _    '

{ printf (\n Insufficient arguments); getchQ;    

exit (0); .

} , , fp = fopen (argv [1], w) ; for (i = 2 ; j < argc; i++)

fprintf (fp, % sb, argv [i]);

fciose(fp);

getch ( ) ;    .

i

Ans. (b) See Q. No. 4.(c) of 2002.

Ans. (c) See Q. No. 4.(a) of 2006.

11. (a) What is the difference between iterative function and recursive function? 9

(b) Write a C program to find factorial of a number using iterative function as well as recursive function.        3 + (6 = 6)

Ans. (a) Recursive Function : A function calls itself in its body, then the function is called recursive function. The recursive function has two conditions, first, the function must be written in a recursive form and second, the function must contains a stopping condition.

Iterative Function : At every iteration we call the function. The stopping condition depends on the iteration.

Ans. (b) Factorial of a number:

Iterative Function

Recursive Function

void main ()

long fact (long);

{ long i, n. f = 1, fact (long);

void main ( )

printf (Enter the number);

{ long i, n;

scanf (% /d, &n);

printf (Enter the number);

for (i = n ; i >  1 ; i--)

scanf (% /d, & n);

f = f* fact (i);

printf (The result is % /d, fact (n));

printf (%/d, 0;

getch ();

getch ();

}

}

long fact (long x)

long fact (long x)

{ if (x = = 1 >

{ return (x);

return (x);

}

> else

return (x* fact (x - 1)) ;

}







Attachment:

( 0 Votes )

Add comment


Security code
Refresh

Earning:   Approval pending.
You are here: PAPER West Bengal Institute of Technology (WBIT) 2008-2nd Sem B.Tech Electronics and Communications Engineering Electronics & Comm ( - ) Basic Computation & Principle of Computer Programming (solved) - Ques