WBUT Exam Papers EE Introduction To Computing B Tech 2nd Sem 2007

WBUT Exam Papers EE

Introduction To Computing B Tech 2nd Sem 2007

 

Time ; 3 Hours

Full Marks : 70

Group-A (Maltiple Choice Questions)

  1. 1.   Choose the correct alternative in each of the following :
  • , 10 * 1 – 10
  • (i)       , ‘Inhexadecimal number system, F is equivalent to the number in decimal. .

(a) 10          (b) 12     (c) 16       (d) 15 .

Ans. is : (d)

(ii)          Which are of the following is conditional operator?

(a) ?:          (b) if     (c)<

Ans. is : (a)

(iii)       What will be the value of i & m after executing the following code? int i =5, m,       ‘

m i++                   •

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

Ans. is : (c)

[Note : In this case first assignment is done, i.e., m holds the value = 5 and after that i will be increased by 1, i.e. 6 here] .

(iv)       During storing of numbers in computer memory positive sign is denoted by

 

(a) 0 Ans. is : [7a

(c) +

(d)

(b) 1

 

, (v) Number of bytes required for double is ’ (a) 8 ~   (b) 4 * (c) 2

Ans. is : ■[■(a) [

[Note : Byte required for float is 4

So „       „ double is 4 x 2 = 8 bytes]

What will be output of the following Code?

(vi)         int i, f = 1 ; –

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

f=f*i; printf(“%d”);

(a) 0              (b) 1    (c) 120

 

The answer is not in the list. v

Because, at the end of the execution of the for loop i will contain the value 6 & came out from the for loop as condition fails. So, now f = 1 *6 = 6 . So, this program will print 6, which is no in the list.

(vii)       Which of the following is not used as secondary storage ?

(a)

Semiconductor memory. (b) Magnetic disks

(c) Magnetic drums      . (d) Magnetic tapes.

Ans. is; (a)

(viii)     The ALU of Computer normally contains a number of high speed strong elements called

(a)  Semiconductor memory  (b) Registers

(c) Hard disit-           (d) Magnetic disk.

Ans. is : p(d)

[Note : Though ALU does not contain any register, actually the container is CPU, ALU & register both are parts of CPU]   . .

(ix)         The register which contains the instructions that are to execute is known as

(a)                                                                                                                                              

Index register    (b) Instruction register

(c) Memory address register  (d) Memory data register

Ans. is : (b)

(x)         A 32 bit microprocessor has the word length equal to

(a)   2 bytes     (b) 1 bytes  (c) 4 bytes   (d) 8 bytes

Ans. is : (c)

(xi)         The union holds

(a)

one object at a time  (b) multiple objects

(c) both (a) & (b)        (d) none of these.

The Ans. is : (a) / (d)

(xii)       The function used to detect the end of file is

(a)    eof ( )     (b) ferror  (c) fputs   (d) fgetch

The Ans. is : (a)

Group-B (Short Answer type Questions)

Answer any three questions.         3><5

  1. 2.              Write a C program for checking whethers a number is prime or not.  5

Sol.: # include <stdio.h>              ‘ >

#

include <conio.h>  ‘

void main ()

– ■ * WBUT (COMPUTER) QUESTIONS—2007

‘ . ‘ . int n, test, prime = 1 ; clrscr ( );  . *

print f (“Enter the no ; \n”) ; j

–                        scanf (“%d”, & n );

for (test ** 2 ; test < » sqrt(n); test ++)   ,    ‘

■ ^ ‘. .. ■ ‘ ” ■ ‘■ ■ ‘ : ‘ ■ ‘ ■ – – .                       if (n%test -~Q)               .          , ,,

{prime * 0; ,                                   ‘                                                                      .

. ‘ break; ■’ ■ – ‘          . V ; ‘ v ■ ■■ ”   •

} ■

I ’ .              .

if (prime)                                    ,        .

printf (“%<1 is a prime no : \n,’’n); else   ‘

printf (“%d is not a prime no : Yn”, n) ; getch ();

} . ‘

  1. 3.                                                                                                                                                                                                                                                                        (a) Write down the difference between Compiler and Interpreter.            1

(b)      Briefly describe the functions of memory unit and discuss, its various parts. 2

(c)      Write down the generation wise development of the computer hardware. 2

Ans. (a) Complier is a program which goes through the whole high, level language program and shows the error after checking the whole program (if any), after correcting the error manually we have to recompile it & it converts the prog, into machine code. But in the case of interpreter it checks line by line the program, if in any line it finds any eiror then immediately stops checking & print the error, You have to every time correct the error & then go for the further interpretation. [And also see the Q. No: 3(b) of 2005].

Ans.(b) Function of Memory unit. Memory unit is used to store data permanently for longer period of time.   .

Power memory devices are:          ‘           .

(1)      Harddisk/magnetic disks

(2)      floppy disk

(3)      Optical disk/ CD-ROM

(4)      DVD ROM

(5)      Magnetic tape.

 

*              . . WBUT SOLVED BOOK

Ans.(c)

Generations

HD used ‘
1st -> Vacumetube
2nd -> Transistor ;
3rd -> Intigrated Ckt
4th   Very large scale Intigration
5th   Ultra language Scale Intigration

 

  1. Stale the output of the following program codes with your justification about how the output obtained.   *

(a)   Void main ()

\ { . ‘ ■

‘ int i, j;    ‘

for { i = 1 ; i< = ; i++ )

{ . • for {j = 1 ;j < = 2 ;j-K}

if { i = =j )

continue;      .

printf ( “jt\n% d% d\n”. i. j );

 

Theoutput will be : I 2 : w      ; • . .. i .. :

4 21

Initially i & j get the value 1; & when it goes for condition checking, it becomes true & than the continue statement brings the control to the starting point of the current block, means j-H- byskiping the printf (unction. Now the ‘value of j is 2 after increment which does not satify the condition of if & print 1 2. Again j increased by Vbut 3 is greater than 2 so condition fails.Now i is incremented by 1 & igetsthevakie 2 & at die same time value of j is 1. So it will print 2 1, as the condition of if jsnot satisfied Now, i = 3, condition failed So, the output will be 12 .21

(b)  Vbid main ()

{ . . . ■ int n = 8 ; n = n « 2 ;

printf (“\n n = %d”, n);

 

It will print 32.

Because, 8 is binery is 1000, now 1 is shifted by 2.

0 0 0 0 1 0 0 0 after shifting :

0 0 0 10 0 0 0 . .

Now, 100000 is equivalent to 32 in decimal digit. So. the output will be 32.

5. (a) Draw the flow chart to display the first n terms of the Fibonacct scries. The first two terms of the series are respectively land 1. The nth term of the series. F is defined as F„ = F,,., + F^j •

Ans. Flow chart of Fibonacci series

 

Ans. Algo to And the sum of 1st n even numbers. ,

Step 1 : Intialize i & sum

–      i : = 2 ; sum : = 0 ;    •

Step 2 : take n as input          v

Step 3 : check the condition, wherter i is greater then equal to n or not If yes than goto sfep 7 , Step 4 : Incriment i by 2 [ i+: = 2]                                     ‘

Step 5 : Calculate the sum, sum ; = sum+ i;

Step 6: Goto step 8

Step 7 : print the sum as output     ,          .

Step 8 : Exit  ‘                   .

  1. 6.  (a) What is recursion ? Explain with an example.

(b)      What is a ternary operation?

Ans. (a) Recursion means the self reference i.e., the defination of recursive function is based on itself. When a called function in turn calls another function a process of’chaining’ Occurs, Recursion is a special case of this process, where a function calls it sekf.

Simple ex : main ( )

{ printf (“This is on example of recursion\n”);    ‘

main (),                 .

Another example of recursion to evaluate factorial of n : factorial (int n)

■’ ‘■ – ‘■ ■. int fact;

if ( n= =1 )

return (1);

else         .. ‘

fact = n* factorial (n -1);

return (fact);       =

• Ans. (b) See Year 2002 Q. No. 6 (a)

‘                                                    Group—C

(Long Answer type questions)

Answer any three questions.

  1. 7.                                                                                                                                                                                                                                                                         (a) How can you represent a string Ming the C programming language?      1

(b)    Name any five string functions whose prototype is defined in the string, h header file. Explain the work of any two of them.  5

(c)     Write a C program to find the number of vowels and consonants in a line text. 4

(d)    Write a C program to convert all lower case alphabets to upper case alphabets, a line of text                     5

Ans. (a) Declaring a string :

Char city [10];

char name [20] ;

[Note . When the compiler assigns a character string to a character array, it automatically suppliers a null character (W) at the end of the String.]

Initializing if => fhar string [ ] = {‘G’, ‘0‘, ‘D’, ‘NO’}; ;

or, Chhar str [10] – “GOD”

Read it.from keyboard => Char adderss [10]

Scanf (“%S”, address); print the Output => printf (“%S”, address) ;

Ans. (b)               ‘     .

String Function   Action

Strcat ()   Concatenates two strings

Strcmp ()   Compares two strings

Strcpy ( ) – Copies one strings over another .

Strlem ( )  finds the length of a string

Strncpy ( ) It copies only the left most n character of the source strings to the

target string Variable

Strcat ( ) : The strcat function joins two strings together ljke => strcat (string 1, string 2) String 1 & String are character array. When the function is executed, string 2 is appended to string 1. It does so by removing the null character afthe end of string 1 & placing string 2 from there. For example—

0 1 2 3 4 5 6 7 8 9 String 1 = V E R Y

0 1 2 3 4                ‘                 –

String 2 = B A D \ 0                              ‘

 

Now after concatination we get => . ? _

Strcat (string 1, string 2)

0                1 2 3 4 5 6.7 8 9

V.;! E ; R . R B …A. D , .       –

Stt«rap (r) ;.lt compares two strings identified, bythearguments ^nd has a value O if they are equal. If they are not, it ha& the ayjnerjc difference between , the first nonmatching characters in the strings,   ,

like =?> strcmp (string 1, string 2)

String 1 & String 2 may be string variable or string constant.

Ex : Strcmp (“their”, “there”) ;

will return a value of-9 which is the numeric difference between ASC II T & ASCII ‘r\

Strcpy ( ) : The strcpy function works almost like a string-assignment operator, like -» strcpy (str 1, str 2) ; and assigns the contents of strings to string 1. String 2 may, be a character array variable or a string constant. For example : strcpy (city, “DELHI”) ; will assign the string “DELHI” to the string variable city. –

Str len ( ) : This functions counts & retumg the member of characters in string. It takes the form n = strlen (string) ; :

Where n is an integer variable, which receives the value of the length of the string.

Ans. (c)                             .

#  include < stdio . h >

include < string, h >

U include < conio . h >

Void main ( )

{ C har Str [ 50 ] ;

Int i = 0, x = 0, y = 0, n, b, c ; clrscr ();

printf (” Enter the String ” \n”) ;              .

gets (str);      ,

n = Strlen (Str               .•                 While(SStr{ i jl =’Wy; *                       .

{ if ( (Str [i] = = ’a’) || (Str [i] = = ’e’) || <Str [i] = =’j’)

|( (Str [i] = = ’O’) || (Str [i] = =’u’) )     »

. x++;                    .       ■ :

if (( Str [i] >*0′) & & (Str [i] < ‘9’))

 

if (Str [i] — * ‘)                      .

■          b++; . ; . . ■ ■ i++;

C = n – (x+y+b) ;                          .

printf (f‘The number of Vowels are %d\n x) ;

prirttf(“The. number of Vowels are %\n” ; 3x) ;     _ .

printf (“The number of Consonenta are %d\n”, c) ; ’

getch (); •

] // end of main Ans. (d)

#  include < stdio> main ()

#  char Srr [50] ; •

int i = 0

  1. (a) Write a C program to create a copy of a text file “file 1. text” into another, “file 2. text      9
  2. (b)    What is the difference in opening a file in “r+” and “w+” modes?                   3

(c)            What do the printf 0 and functions do?                                                              3 Ans. See 2004 Q, 11 (ii) ,

Ans. (b) In the case of r+ the existing file is opened fo the begining for both reading & writing w+ open the file for writing only same as w except-both for reading & writing* *

‘ Ans. -(C) Tifie functian f prmtf writes aset ofdata values te file. The operation is same as printf onlyiWffetenceris it works on fiie. n ^     ! i >

Format f;p#mtf (% “eofi1rolstring’,| list)?j fp iS a ftle pointer. »??;                                         J

The funetioa fread 0 ) Bftams the number of record read. ‘ >>

Input) : “*• •’ ”8″ ’’        ”V ‘ * ’ r. ‘ ” ~ ‘  .

(b)        Write a C program to accept a string asa command fine argument and hence find its length. V   ,    % ‘ • ‘

Ans. (a)                            .    .

 

#  include < stdio . h >   .

#  include < conio . h >   –

Void main ()■                ’          *

{ int i. j, n ; clrscr ( ) ; printf ( “Enter the number of row : \ n”); scanf (“%d”, & n) ;    .

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

{ for (j > 4 ; j > = i; J —)

 

printf (“ * ”); printf (“

 

Ans. (b) See Q. No. 9(a) of 2003.

10^a) What «re structure and structure variable? What are arry A subscripted variable? Compare array & structure data type with suitable examples. 5

■         (b) WKat are the functions of a CPU ? How does the CPU perform them? 5

(c)     A magnetic disk pack has 12 surfaces out of which 10 are readable. Each surface has SO tracks and each track b divided into a number of sectors. If the total capacity of the disk pack is 50000 K bytes, and the capacity of each

  • sector b 512 bytes then.
  • (i)     flow many cylinders are present in the disk pack?                                                                                                    .3
  • (H) How many sectros are present on each track?                                      2

Ans, (a). Structure is an user defined data type, a mechanism for packing data of different types. A structure is a convenient tool for handling a group of logically related data items. Structures help to organize complex data in a more meaningful way.

After defining a structure format we can declare variables of that type. A structure variable declaration is similar to the declaration of variables of any other data types.

559

Like, structure book-bank

‘ f ‘ • ‘ char title [20];                         ,

1st pages‘

float price ;                           –

Struct book-bank book 1, book 2 ;

Here book 1 & book 2 are structure Variables. ,

An array is a fixed size sequenced collection of elements of the same data type. ‘

a [i] is called subscripted variable where i is called subscript

#    See privious year.

Ans. (b) See 2002, Q. No. 3(a) for CPU ohly.

Ans. (c)(i) No. of cylinders – 12 * 50 = 600

*

5000×1024

(ii)     . No of sectors =                      10000

  1. 11.                                                                                                                                                                                                                                         Write short notes on any three :                                        3×5 = 15

(a)    Enumerated data types

(b)    Dynamic memory allocation

(c)     Array of pointers   ‘

(d)    Multiprogramming Operating System.            ■

Ans. (a) Enumerated data type : It is an user-defined data type provided by ANSI standard. It is defined as follows :

enum identifier { value 1, value 2 …. value n } ;

The “identifier” is an user-defined enumerated data type which can be used to declare variably that can have One of the values enclosed within the braces.

We can also declare it like—>

enum day { Monday, Tuesday,     , Sunday } ;

Here the compiler autometically assigns integer digits begining with 0 to all the enumeration constants.. That means, Moday = 0.

Tuesday = 1

Now, enum day { Mon = 1, Tue,Sun} ;

 

Here, the constant Mon is assigned the value of 1. The remaining constants are assigned values that increase successively by 1.

Ans. (b) See 2005, 9.(e).

Ans. (c) See 2005, 9.(d).  ‘

Ans. (d) Multiprogramming Operating System ; An operating system proyides the environment within which programs are executed. One of die most important aspects of operating systems is the ability to multiprogram. A single user can not, in general, keep either the CPU or the I/O devices busy at all times. Multiprogramming increases CPU utilization by organizing jobs so that the CPU always has one to execute. The operating system keeps several jobs .in memory simultaneously. This set of jobs can be a subset of the jobs kept in the job’pool—which containg al l jobs the enter the system—since the number of jobs that can be kept simultaneously in memory is usually smaller than the number of jobs that can be kept in the job pool. The OS picks & beging to execute one of the jobs in memory. Eventually, the job may have to wait for some task, such as an I/O operation, to complete. In a non­multiprogrammed system, the CPU would sit idea. In a multiprogrammed system, the . operating system simply switches to, and executes, another job. When that job needs to waft, the CPU is switched to another job, and so on. Eventually, the first job firshes watting & gets the CPU back. As long as at least one: job needs to execute, the CPU is never idea. ^ ;

Leave a Comment