How To Exam?

a knowledge trading engine...


Birla Institute of Technology (BIT Mesra) 2007 B.E Development & Use of Computer Software - Question Paper

Saturday, 19 January 2013 01:05Web

Birla Institute of Technology & Science, Pilani
First Semester 2007-2008
Comprehensive exam
Course No. :BITSG644 Course Title :Development & Use of Computer Software
Duration :2 Hrs Date:08/12/2007
Q1 Multiple option and short ans ques.. [Question one to 62- half mark each].


1. What do you call a style of programming that defines how programs are going to be approached and solved?

2. What do you call a step-by-step description of a procedure for solving a problem? (This description lists the actions, in order, that will solve the issue.

3. What are the 3 types of control flow in structured programming?

4. In general (other than within string constants like "Hello World" and a few obscure constructs), what effect does the amount of whitespace (spaces and tabs) ranging from code elements have on a C program's compiled output?
a. Spaces are ignored, tabs have meaning.
b. Spaces and tabs are both ignored.
c. Tabs are ignored, spaces have meaning.
d. Spaces and tabs both have meaning.

5. Why are line numbers used when writing C source code?
a. To indicate the begin of a new line.
b. To make the code easier to learn.
c. To maintain order of the lines at compile time.
d. They aren't used.

6. How does 1 indicate that certain text is to be treated as a "comment" in the classic C language?
a. Place the text ranging from /* */ .
b. Place 'COMMENT:' before the text.
c. Place '#' before the text.
d. Place the text ranging from # and #.

7. What will this piece (snippet) of C code print to the screen?
printf("Hello World");
/* This is a comment
printf("Hello Again");
This is a different comment */
a. Only "Hello World".
b. Only "Hello Again".
c. Both "Hello World" and "Hello Again".
d. Neither.

8. In a C program, the 1st statement that will be executed is:
a. the 1st executable statement of the program.
b. the 1st executable statment after the comment /*start here*/
c. the 1st executable statement of the main() function.

9. The statement: int *jack
a. declares that all variables ending with jack are ints.
b. is a pointer declaration. jack is a pointer to an int variable.
c. declares that jack is the address of a variable and that the address is an int.

10. True or false? The C language is normally used for object-oriented programming.
a. True
b. false

11. The smallest info units can not represent much info is called

12. Is there a difference ranging from i++ and ++i ?
a. No difference.
b. i++ is illegal.
c. ++i is illegal.
d. Sometimes there's a difference, sometimes not.

13. Say you had a piece (snippet) of C code that looked like this:
if( i > 0 )
j = 5;

Let's say you rewrote it to look like this:
if( i > 0 ) j = 5;

What is the difference ranging from the 2 snippets?
a. The original is illegal.
b. They are both illegal.
c. The modification is illegal.
d. Nothing, and both are legal.

14. In C programming, what does i equal at the end of the subsequent piece (snippet) of code?
i = 1;
i *= 5;
i += 3;
a. 5
b. 3
c. 1
d. 8

15. In the C language, how does 1 write the statement, "if i NOT equal to zero"?
a. if ( i != 0 )
b. if ( i NOT= 0 )
c. if ( i == 0 )
d. if ( i = !0 )



16. 10. When programming in C, what will j equal at the end of the subsequent piece (snippet) of code?
i = 1;
j = 0;
if( i = one ) j = 3;
if( i = two ) j = 5;
a. 5
b. 3
c. 0
d. None of these

17. What is the difference ranging from the rand() function and the srand() function?

18. What is the output of the subsequent program?
#include
int taxi(int);
void bus(int);

void main(void)
{
int myInt1 = 0, myInt2 = 12;
myInt1 = taxi(myInt2);
printf("%d\n", myInt1);
}

int taxi(int a)
{
a = a * 2;
bus(a);
return a;
}

void bus(int x)
{
x = x * 2;
return;
}

19. #include
void main(void)
{
int a=3, b=2;
printf( "%d*%d", a, b);
}
What is the output?

20. #include
void main(void)
{
int i = 0, sum = 0;
while( i < three ) {
printf( "%d ", i);
sum += i;
i++;
}
printf( "%d", sum);
}
What is the output?

21. #include
#include
struct company {
char ticker[5];
float price;
};
void myFunction(struct company []);
void main(void)
{
struct company cos[3];
myFunction(cos);
printf("%s %.2f\n", cos[2].ticker, cos[2].price);
}
void myFunction(struct company comps[])
{
strcpy(comps[0].ticker, "IBM");
comps[0].price = 115.59;
strcpy(comps[1].ticker, "MSFT");
comps[1].price = 29.33;
strcpy(comps[2].ticker, "INTC");
comps[2].price = 23.63;
}
What is the output?

22. #include
void main(void)
{
int i, sum = 10;
for( i = 3; i >= 1; i-- )
sum = sum - i;
printf( "%d", sum );
}
What is the output?

23. #include
void main(void)
{
float myFloat = 1234.5678;
printf( "%.3f", myFloat );
}
What is the output?

24. #include
void func1( int );
void func2( int * );
int func3( int );
void main(void)
{
int myInt = 10;
func1( myInt );
printf( "%d\n", myInt );
}
void func1( int a )
{
a = two * a;
func2( &a );
}
void func2( int *x )
{
*x = *x * 2;
*x = func3( *x );
}
int func3( int z )
{
return z * 2;
}
What is the output?

25. #include
void main(void)
{
int i = 5;
do {
printf("%d ", i);
i--;
} while( i > three );
}
What is the output?

26. #include
void main(void)
{
char myString[] = "Wassup!";
int i = 0;
while( myString[i] != 0 ) {
if ( myString[i] == 's' )
myString[i] = 'z';
else if ( myString[i] == 'u' )
myString[i] = 'a';
i++;
}
printf( "%s", myString );
}
What is the output?

27. #include
int myFunc( int * );
void main(void)
{
int i = 7, j = 10;
int *ptr1 = &i;
int *ptr2 = &j;
*ptr2 = myFunc( ptr1);
printf( "%d %d", i, j );
}
int myFunc( int *p1 )
{
*p1 = *p1 * 10;
return *p1;
}
What is the output?

28. #include
char myFunction( char );
void main(void)
{
int i = 'x', j = 'y';
j = myFunction( i );
printf("%c %c", i, j);
}
char myFunction(char a)
{
char b;
b = a + 2;
return b;
}
What is the output?

29. #include
void main(void)
{
int a=1, b=2;
printf( "%d %d", a, a+b);
}
What is the output?
30. The subsequent program contains several global variables. Trace through the program and Write down the output in the order that they would appear when the program is executed..
#include
void xyzzy(int) ;
int a = 3, b = 6, c = 9, d = 12 ;
void xyzzy(int a) {
int b ;
b = a - one ;
c = two * b + 12 ;
d = b + c + three ;
a = c - b ;
printf("xyzzy: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
}
main() {
int b = 5, d = 10 ;

printf("main: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
xyzzy(a) ;
printf("main: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
}

31. What value is stored in marks[i] if the value -10 is entered?
#define LIMIT 100
main()
for (i= 0; i < LIMIT; i++){
printf("\nEnter mark:");
scanf("%d", &score);
if (score <0)
continue;
marks[i] = score;
}
}
a. 10
b. -10
c. 0
d. no value is stored

32. .What is the output of the subsequent program?
#include
main()
int oldval,newval = 0;
int i;
for (i=0;i<10;i++){
oldval = newval;
newval = i;
}
printf("%d",oldval);
}
a. 8
b. 9
c. 10
d. 0123456789

33. What is the output of the subsequent program?
#include
int func (int n){
int f,i;
f=1;
for(i=1; i<=;n;i++){
f *=i;
}
return f;
}
main(){
printf("%d\n",func(4));
}
a. 3
b. 4
c. 10
d. 24

34. What is the output of the subsequent program?
#include
int a,b;
void f1 (int *r, int *s){
int temp;
temp = *r;
*r = *s;
*s = temp;
}
void f2 (int *x, int *y){
if (*x > *y) f1(x,y);
}
main(){
a = 64, b = 42;
f2(&a;,&b;);
printf("%d,%d\n",a,b);
}
a. 64,42
b. 42,64
c. 64,64
d. 42,42

35. What is the output of the subsequent program?
#include
int a,b;
void f1 (int r, int s){
int temp;
temp = r;
r = s;
s = temp; }
void f2 (int x, int y){
if (x > y) f1(x,y); }
main(){
a = 64, b = 42;
f2(a,b);
printf("%d,%d\n",a,b);
}
a. 64,42
b. 42,64
c. 64,64
d. 42,42

36. #include
void main(void)
{
char myChar = 'K';
printf("%c", *&*&*&*&*&myChar);
}
What is the output?

37. #include
void main(void)
{
int i = 20, j = 10;
if ( i < j && i == 10 )
printf("i < j && i == 10");
else if ( i < j || i == 10 )
printf("i < j || i == 10");
else
printf("NEITHER");
}
What is the output?

38. What is the output of the program below?
#include
void mysteryFunction(char arr[]);
void main(void)
{
char myString[] = "This is a string.\n";
mysteryFunction(myString);
printf("%s", myString);
}
void mysteryFunction(char arr[])
{
int i = 0;
while(arr[i] != 0) {
if(arr[i] == 'a' || arr[i] == 'e' || arr[i] == 'i') {
arr[i] = 'x';
}
i++;
}
}

39. In the statement: scanf("%s",name) below, name corresponds to:
main(){
char name[21];
scanf("%s",name);
}

a. the value of name[0].
b. the address of the 1st element of the name array.
c. the contents of the name array.

40. int main()
{
int cnt = 5, a;
do {
a /= cnt;
} while (cnt --);
printf ("%dn", a);
}
a. 0
b. 1
c. Run time fault
d. Insufficient data, value cannot be determined

41. main()
{
int *ptr, i;
ptr = (int *) malloc( four * sizeof(int));
for (i=0; i<4; i++)ptr[i]=i;
printf("%d,", *ptr++);
printf("%d,", ++(*ptr));
printf("%d,", *++ptr);
printf("%dn", ++*ptr);
}

a. 0,2,2,3
b. 1,2,2,3
c. 0,2,1,2
d. 1,2,1,2

42. What is the output?
int main()
{
struct num {
int x,y;
} val[4] = {1,1,2,3,4,5,6,7};
struct num *ptr = val;
int i=0;
for(;i<4;i++) {
ptr->x = ptr->y, ++(ptr++->y);
printf("%d,%d ", val[i].x, val[i].y);
}
}
a. 1,3 2,5 4,7 6,9
b. undefined behavior
c. 1,2 3,4 5,6 7,8
d. segmentation fault

43. What is the output
#define INDX(x) (++indx[x][ptr[x-1]],&indx[x][ptr[x-1]])
int main()
{
int indx[6]={0,1,2,3,4,5};
int i=10;
char arr[][20]={"%hs'nt %s %s","%dbool", "?n%shis? ",};
char *ptr[3];
ptr[0]=&arr[0][0];
ptr[1]=&arr[1][0];
ptr[2]=&arr[2][0];
printf(INDX(1),INDX(3),INDX(2));
}
a. isn't this cool
b. compile time fault
c. This is bool

44. What is the output
int main()
{
static a=3;
printf("%d",a--);
return a>0 ? main():0;
}
a. 3210
b. 333
c. 321
d. 210

45. What is the output
void main()
{
char *s[]={ "miller","miller","filler","filler"};
char **p;
p=s;
printf("%s ",++*p);
printf("%s ",*p++);
printf("%s ",++*p);
}
a. iller miller iller
b. iller miller filler
c. iller iller filler
d. iller iller iller

46. What is the output
int main()
{
int x=0;
for(;x<20 && printf("%d ",x);x++)
switch(x)
{
case 0:x++,x*=2;
case 1:x+=2;
case 99:x+=6;
default:x+=3;
break;
} }
a. 0 12 16
b. 0 13 17
c. 0 14 18
d. 0 11 15 18

47. What is the output
int main()
{ char boolean[][6]={"TRUE","FALSE"};
printf("%s",boolean[(unsigned int)-1 == ~0]);
}
a. TRUE
b. FALSE
c. run time fault
d. compile time fault

48. What is the output
char *getptr()
{ static char ptr[10] = "123456789";
return ptr; }
main()
{
char *ptr="00000";
strcpy(getptr()+4,ptr);
ptr=getptr();
5[strcpy(ptr,"12345")]='6';
printf("The string is : %s",getptr());
}
a. 123456789
b. run time fault
c. 123456000
d. 12345

Use the subsequent code segment to ans ques. 70 through 73. (tick all the accurate answer(s))
main()
{
int m , months , years ;
float payment , rate , mrate , balance = 0.0 ;

if( scanf( "%f %f %d" , &payment , &rate , &years ) == three )
{
months = years * 12 ;
mrate = 1.0 + ( rate / 100.0 ) / 12.0 ;

for( m = 0 ; m < months ; )
{
balance += payment ;
balance *= mrate ;
m ++ ;
printf( "%d %.2f\n" , m , balance ) ;
} }
else
printf("Error studying input.\n") ;
}
49. Which of the subsequent values will never be assigned to the variable months by the program?
a. 6
b. 72
c. 36
d. 88
50. Suppose "500 12 10" was entered as input for the program. What is the value assigned by the program to the variable mrate?
a. 101.0
b. 1.01
c. 1.166667
d. 1.0
51. Suppose "100 7.5 5" was entered as input for the program. What is the final value of the variable m?
a. 1200
b. 144
c. 60
d. 59
52. Which of the subsequent lines would never be printed by the program (for any inputs)?
a. 60 1000.00
b. 105.3 1023.00
c. 67 1,734,704.23
d. 360 187000.00
Use the subsequent code segment to ans ques. 53 and 54.
main()
{
int i = 0 , j = 0 ;
scanf( "%d %d" , &i , &j ) ;
i += two ;
j -= two ;

if ( ( i = seven ) && ( j = nine ) )
printf( "yes\n" ) ;
else
printf( "no\n" ) ;
printf( "%d %d\n" , i , j ) ;
}
53. Under what circumstances would the program print "yes"?
a. Always.
b. Never.
c. If the 1st number entered was five or the 2nd number entered was 11.
d. If the 1st number entered was five and the 2nd number entered was 11.
54. Suppose you entered "9 7" as the input for the program. What would the final line of output from the program look like?
a. 11 five
b. 7 nine
c. 9 seven
d. 5 11
Use the subsequent code segment to ans ques. 55 through 58.
void ducs( int n , int m ) ;

main()
{
int x = 5, int y = seven ;
ducs( x , y ) ;
printf( "%d %d\n" , x , y ) ;
ducs( x , y ) ;
}
void ducs( int a , int b )
{
int c ;
a *= two ;
b *= two ;
c = a ;
a = b ;
b = c ;
}
55. What value does c have at the end of the 1st call to ducs?
a. 5
b. 7
c. 10
d. 14
56. Which of the subsequent is the accurate output from the program?
a. 5 seven
b. 10 14
c. 7 five
d. 14 10
57. What is the final value of the variable x?
a. 5
b. 7
c. 20
d. 28
58. What value does b have at the end of the 2nd call to ducs?
a. 10
b. 14
c. 20
d. 28
Use the subsequent code segment to ans ques. 59 through 62.
float titania( float thisbe , float pyramus ) ;
int puck( float *lysander , float *hermia ) ;

main()
{
float x = 1.3 ,float y = 3.0 ;
float z = 9, float *px ;
float *py , float *pz ;

px = &x ;
py = &y ;
pz = &z ;

z = titania( x , y ) ;
if ( puck( px , py ) )
printf( "%f %f %f\n" , x , y , z ) ;
else
printf( "%f %f %f\n" , z , y , x ) ;
printf( "%f %f\n" , z , *pz ) ;
}

float titania( float demetrius , float helena )
{
return demetrius * helena ;
}

int puck( float *lysander , float *hermia )
{
int bottom ;

bottom = *lysander ;
*lysander = *hermia ;
*hermia = bottom ;

return ( (*lysander) > (*hermia) ) ;
}
59. What is the final value for the variable z?
a. 3.9
b. 1.3
c. 3.0
d. 9.0
60. What is the final value for the variable y?
a. 1.3
b. 3.0
c. 3.9
d. 1.0
61. Which of the subsequent is the accurate output from the 1st printf statement executed by the program?
a. 3.000000 3.900000
b. 1.300000 3.000000 3.900000
c. 3.000000 1.000000 3.900000
d. 3.000000 1.300000 3.900000
62. Which of the subsequent is the accurate output from the last printf statement executed by the program?
a. 3.900000 -2017374568
b. segmentation fault
c. 3.900000 3.900000
d. bus fault

63. Write a for loop that can change the subsequent while loop. [1 mark]
i = 0;
while(i < 10) {
printf(ā€œ%d\nā€, i);
i++;
}

64. Write a function that receives two floats as arguments and returns the avg. of the two floats. [2 marks]

65. #include [2 marks]
int getChoice(void);
void processChoice(int);
void main(void)
{
int choice;
option = getChoice();
while ( option != four ) {
processChoice( option );
option = getChoice();
}
}
int getChoice(void)
{
int choice;
do {
printf("1. Deposit\n");
printf("2. Withdraw\n");
printf("3. Check balance\n");
printf("4. Quit\n");
printf("==> Your choice? ");
scanf("%d", &choice);
} while ( option < one || option > three );
return choice;
}
void processChoice( int option )
{
switch ( option ) {
case 1:
printf( "Depositing...\n" );
break;
case 2:
printf( "Withdrawing...\n" );
break;
case 3:
printf( "Getting balance...\n" );
break;
}
}
What is the output from the processChoice
function if the user inputs a 3?

The user cannot quit this program. Why
not?




To fix this, change







Birla Institute of Technology & Science, Pilani
First Semester 2007-2008
Comprehensive exam
Course No. :BITSG644
Course Title :Development & Use of Computer Software
Duration :1 Hr Date:08/12/2007


Q1 What is software engineering? 5 marks

Q2 elaborate the attributes of good software? 5 marks

Q3 elaborate the key challenges facing software engineering? 5 marks

Q4 Differentiate between 10 marks
a. Evolutionary development And Formal systems development
b. Reuse-oriented and Incremental Development






Birla Institute of Technology & Science, Pilani

Birla Institute of Technology & Science, Pilani

First Semester 2007-2008

Comprehensive Examination

Course No. :BITSG644

Course Title :Development & Use of Computer Software

Duration :2 Hrs Date:08/12/2007

Q1 Multiple choice and short answer questions. [Question 1 to 62- half mark each].

 


1.     What do you call a style of programming that describes how programs are going to be approached and solved?

 

2.     What do you call a step-by-step description of a procedure for solving a problem? (This description lists the actions, in order, that will solve the problem.

 

3.     What are the three kinds of control flow in structured programming?

 

4.     In general (other than within string constants like "Hello World" and a few obscure constructs), what effect does the amount of whitespace (spaces and tabs) between code elements have on a C program's compiled output?

a.   Spaces are ignored, tabs have meaning.

b.   Spaces and tabs are both ignored.

c.   Tabs are ignored, spaces have meaning.

d.   Spaces and tabs both have meaning.

 

5.     Why are line numbers used when writing C source code?

a.   To indicate the start of a new line.

b.   To make the code easier to read.

c.   To maintain order of the lines at compile time.

d.   They aren't used.

 

6.     How does one indicate that certain text is to be treated as a "comment" in the classic C language?

a.   Place the text between /* */ .

b.   Place 'COMMENT:' before the text.

c.   Place '#' before the text.

d.   Place the text between # and #.

 

7.     What will this piece (snippet) of C code print to the screen?

printf("Hello World");

/* This is a comment

printf("Hello Again");

This is another comment */

a.   Only "Hello World".

b.   Only "Hello Again".

c.   Both "Hello World" and "Hello Again".

d.   Neither.

 

8.     In a C program, the first statement that will be executed is:

Top of Form

a.   the first executable statement of the program.

b.   the first executable statment after the comment /*start here*/

c.   the first executable statement of the main() function.
Bottom of Form

 

9.     The statement: int *jack Top of Form

a.   declares that all variables ending with jack are ints.

b.   is a pointer declaration. jack is a pointer to an int variable.

c.   declares that jack is the address of a variable and that the address is an int.

10.  True or false? The C language is normally used for object-oriented programming.

a.     True

b.     false

 

11.  The smallest information units can not represent much information is called

 

12.  Is there a difference between i++ and ++i ?

a.     No difference.

b.     i++ is illegal.

c.     ++i is illegal.

d.     Sometimes there's a difference, sometimes not.

 

13.  Say you had a piece (snippet) of C code that looked like this:

if( i > 0 )

j = 5;

 

Let's say you rewrote it to look like this:

if( i > 0 ) j = 5;

 

What is the difference between the two snippets?

a.     The original is illegal.

b.     They are both illegal.

c.     The modification is illegal.

d.     Nothing, and both are legal.

 

14.  In C programming, what does i equal at the end of the following piece (snippet) of code?

i = 1;

i *= 5;

i += 3;

a.     5

b.     3

c.     1

d.     8

 

15.  In the C language, how does one write the statement, "if i NOT equal to zero"?

a.     if ( i != 0 )

b.     if ( i NOT= 0 )

c.     if ( i == 0 )

d.     if ( i = !0 )

 

 

 

16.  10. When programming in C, what will j equal at the end of the following piece (snippet) of code?

i = 1;

j = 0;

if( i = 1 ) j = 3;

if( i = 2 ) j = 5;

a.     5

b.     3

c.     0

d.     None of these

 

17.  What is the difference between the rand() function and the srand() function?

 

18.  What is the output of the following program?

#include <stdio.h>

int taxi(int);

void bus(int);

 

void main(void)

{

int myInt1 = 0, myInt2 = 12;

myInt1 = taxi(myInt2);

printf("%d\n", myInt1);

}

 

int taxi(int a)

{

a = a * 2;

bus(a);

return a;

}

 

void bus(int x)

{

x = x * 2;

return;

}

 

19.  #include <stdio.h>

void main(void)

{

int a=3, b=2;

printf( "%d*%d", a, b);

}

What is the output?

 

20.  #include <stdio.h>

void main(void)

{

int i = 0, sum = 0;

while( i < 3 ) {

printf( "%d ", i);

sum += i;

i++;

}

printf( "%d", sum);

}

What is the output?

 

21.  #include <stdio.h>

#include <string.h>

struct company {

char ticker[5];

float price;

};

void myFunction(struct company []);

void main(void)

{

struct company cos[3];

myFunction(cos);

printf("%s %.2f\n", cos[2].ticker, cos[2].price);

}

void myFunction(struct company comps[])

{

strcpy(comps[0].ticker, "IBM");

comps[0].price = 115.59;

strcpy(comps[1].ticker, "MSFT");

comps[1].price = 29.33;

strcpy(comps[2].ticker, "INTC");

comps[2].price = 23.63;

}

What is the output?

 

22.  #include <stdio.h>

void main(void)

{

int i, sum = 10;

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

sum = sum - i;

printf( "%d", sum );

}

What is the output?

 

23.  #include <stdio.h>

void main(void)

{

float myFloat = 1234.5678;

printf( "%.3f", myFloat );

}

What is the output?

 

24.  #include <stdio.h>

void func1( int );

void func2( int * );

int func3( int );

void main(void)

{

int myInt = 10;

func1( myInt );

printf( "%d\n", myInt );

}

void func1( int a )

{

a = 2 * a;

func2( &a );

}

void func2( int *x )

{

*x = *x * 2;

*x = func3( *x );

}

int func3( int z )

{

return z * 2;

}

What is the output?

 

25.  #include <stdio.h>

void main(void)

{

int i = 5;

do {

printf("%d ", i);

i--;

} while( i > 3 );

}

What is the output?

 

26.  #include <stdio.h>

void main(void)

{

char myString[] = "Wassup!";

int i = 0;

while( myString[i] != 0 ) {

if ( myString[i] == 's' )

myString[i] = 'z';

else if ( myString[i] == 'u' )

myString[i] = 'a';

i++;

}

printf( "%s", myString );

}

What is the output?

 

27.  #include <stdio.h>

int myFunc( int * );

void main(void)

{

int i = 7, j = 10;

int *ptr1 = &i;

int *ptr2 = &j;

*ptr2 = myFunc( ptr1);

printf( "%d %d", i, j );

}

int myFunc( int *p1 )

{

*p1 = *p1 * 10;

return *p1;

}

What is the output?

 

28.  #include <stdio.h>

char myFunction( char );

void main(void)

{

int i = 'x', j = 'y';

j = myFunction( i );

printf("%c %c", i, j);

}

char myFunction(char a)

{

char b;

b = a + 2;

return b;

}

What is the output?

 

29.  #include <stdio.h>

void main(void)

{

int a=1, b=2;

printf( "%d %d", a, a+b);

}

What is the output?

30.  The following program contains several global variables. Trace through the program and Write down the output in the order that they would appear when the program is executed..

#include <stdio.h>
void xyzzy(int) ;
int a = 3, b = 6, c = 9, d = 12 ;
void xyzzy(int a) {
 int b ;
b = a - 1 ;
c = 2 * b + 12 ;
d = b + c + 3 ;
a = c - b ;
printf("xyzzy: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
}
main() {
int b = 5, d = 10 ;
 
printf("main: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
xyzzy(a) ;
printf("main: a = %d, b = %d, c = %d, d = %d\n", a, b, c, d) ;
}

 

31.  What value is stored in marks[i] if the value -10 is entered?
#define LIMIT 100

main()

for (i= 0; i < LIMIT; i++){

printf("\nEnter mark:");

scanf("%d", &score);

if (score <0)

continue;

marks[i] = score;

}

}

Top of Form

a.     10

b.     -10

c.     0

d.     no value is stored
Bottom of Form

 

32.  .What is the output of the following program?

#include <stdio.h>

main()

int oldval,newval = 0;

int i;

for (i=0;i<10;i++){

oldval = newval;

newval = i;

}

printf("%d",oldval);

}

Top of Form

a.     8

b.     9

c.     10

d.     0123456789
Bottom of Form

 

33.  What is the output of the following program?

#include <stdio.h>

int func (int n){

int f,i;

f=1;

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

f *=i;

}

return f;

}

main(){

printf("%d\n",func(4));

}

Top of Form

a.     3

b.     4

c.     10

d.     24
Bottom of Form

 

34.  What is the output of the following program?

#include <stdio.h>

int a,b;

void f1 (int *r, int *s){

int temp;

temp = *r;

*r = *s;

*s = temp;

}

void f2 (int *x, int *y){

if (*x > *y) f1(x,y);

}

main(){

a = 64, b = 42;

f2(&a;,&b;);

printf("%d,%d\n",a,b);

}

Top of Form

a.     64,42

b.     42,64

c.     64,64

d.     42,42
Bottom of Form

 

35.  What is the output of the following program?

#include <stdio.h>

int a,b;

void f1 (int r, int s){

int temp;

temp = r;

r = s;

s = temp; }

void f2 (int x, int y){

if (x > y) f1(x,y); }

main(){

a = 64, b = 42;

f2(a,b);

printf("%d,%d\n",a,b);

}

Top of Form

a.     64,42

b.     42,64

c.     64,64

d.     42,42
Bottom of Form

 

36.  #include <stdio.h>

void main(void)

{

char myChar = 'K';

printf("%c", *&*&*&*&*&myChar);

}

What is the output?

 

37.  #include <stdio.h>

void main(void)

{

int i = 20, j = 10;

if ( i < j && i == 10 )

printf("i < j && i == 10");

else if ( i < j || i == 10 )

printf("i < j || i == 10");

else

printf("NEITHER");

}

What is the output?

 

38.  What is the output of the program below?

#include <stdio.h>

void mysteryFunction(char arr[]);

void main(void)

{

char myString[] = "This is a string.\n";

mysteryFunction(myString);

printf("%s", myString);

}

void mysteryFunction(char arr[])

{

int i = 0;

while(arr[i] != 0) {

if(arr[i] == 'a' || arr[i] == 'e' || arr[i] == 'i') {

arr[i] = 'x';

}

i++;

}

}

 

39.  In the statement: scanf("%s",name) below, name corresponds to:

main(){

char name[21];

scanf("%s",name);

}

 

a.     the value of name[0].

b.     the address of the first element of the name array.

c.     the contents of the name array.
Bottom of Form

 

40.  int main()

{

int cnt = 5, a;

do {

a /= cnt;

} while (cnt --);

printf ("%dn", a);

}

a.     0

b.     1

c.     Run time error

d.     Insufficient data, value cannot be determined

 

41.  main()

{

int *ptr, i;

ptr = (int *) malloc( 4 * sizeof(int));

for (i=0; i<4; i++)ptr[i]=i;

printf("%d,", *ptr++);

printf("%d,", ++(*ptr));

printf("%d,", *++ptr);

printf("%dn", ++*ptr);

}

 

a.     0,2,2,3

b.     1,2,2,3

c.     0,2,1,2

d.     1,2,1,2

 

42.  What is the output?

int main()

{

struct num {

int x,y;

} val[4] = {1,1,2,3,4,5,6,7};

struct num *ptr = val;

int i=0;

for(;i<4;i++) {

ptr->x = ptr->y, ++(ptr++->y);

printf("%d,%d ", val[i].x, val[i].y);

}

}

a.     1,3 2,5 4,7 6,9

b.     undefined behavior

c.     1,2 3,4 5,6 7,8

d.     segmentation fault

 

43.  What is the output

#define INDX(x) (++indx[x][ptr[x-1]],&indx[x][ptr[x-1]])

int main()

{

int indx[6]={0,1,2,3,4,5};

int i=10;

char arr[][20]={"%hs'nt %s %s","%dbool", "?n%shis? ",};

char *ptr[3];

ptr[0]=&arr[0][0];

ptr[1]=&arr[1][0];

ptr[2]=&arr[2][0];

printf(INDX(1),INDX(3),INDX(2));

}

a.     isn't this cool

b.     compile time error

c.     This is bool

 

44.  What is the output

int main()

{

static a=3;

printf("%d",a--);

return a>0 ? main():0;

}

a.     3210

b.     333

c.     321

d.     210

 

45.  What is the output

void main()

{

char *s[]={ "miller","miller","filler","filler"};

char **p;

p=s;

printf("%s ",++*p);

printf("%s ",*p++);

printf("%s ",++*p);

}

a.     iller miller iller

b.     iller miller filler

c.     iller iller filler

d.     iller iller iller

 

46.  What is the output

int main()

{

int x=0;

for(;x<20 && printf("%d ",x);x++)

switch(x)

{

case 0:x++,x*=2;

case 1:x+=2;

case 99:x+=6;

default:x+=3;

break;

} }

a.     0 12 16

b.     0 13 17

c.     0 14 18

d.     0 11 15 18

 

47.  What is the output

int main()

{ char boolean[][6]={"TRUE","FALSE"};

printf("%s",boolean[(unsigned int)-1 == ~0]);

}

a.     TRUE

b.     FALSE

c.     run time error

d.     compile time error

 

48.  What is the output

char *getptr()

{ static char ptr[10] = "123456789";

return ptr; }

main()

{

char *ptr="00000";

strcpy(getptr()+4,ptr);

ptr=getptr();

5[strcpy(ptr,"12345")]='6';

printf("The string is : %s",getptr());

}

a.     123456789

b.     run time error

c.     123456000

d.     12345

 

Use the following code segment to answer questions 70 through 73. (tick all the correct answer(s))

main()

{

int m , months , years ;

float payment , rate , mrate , balance = 0.0 ;

 

if( scanf( "%f %f %d" , &payment , &rate , &years ) == 3 )

{

months = years * 12 ;

mrate = 1.0 + ( rate / 100.0 ) / 12.0 ;

 

for( m = 0 ; m < months ; )

{

balance += payment ;

balance *= mrate ;

m ++ ;

printf( "%d %.2f\n" , m , balance ) ;

} }

else

printf("Error reading input.\n") ;

}

49.  Which of the following values will never be assigned to the variable months by the program?

a.     6

b.     72

c.     36

d.     88

50.  Suppose "500 12 10" was entered as input for the program. What is the value assigned by the program to the variable mrate?

a.     101.0

b.     1.01

c.     1.166667

d.     1.0

51.  Suppose "100 7.5 5" was entered as input for the program. What is the final value of the variable m?

a.     1200

b.     144

c.     60

d.     59

52.  Which of the following lines would never be printed by the program (for any inputs)?

a.     60 1000.00

b.     105.3 1023.00

c.     67 1,734,704.23

d.     360 187000.00

Use the following code segment to answer questions 53 and 54.

main()

{

int i = 0 , j = 0 ;

scanf( "%d %d" , &i , &j ) ;

i += 2 ;

j -= 2 ;

 

if ( ( i = 7 ) && ( j = 9 ) )

printf( "yes\n" ) ;

else

printf( "no\n" ) ;

printf( "%d %d\n" , i , j ) ;

}

53.  Under what circumstances would the program print "yes"?

a.     Always.

b.     Never.

c.     If the first number entered was 5 or the second number entered was 11.

d.     If the first number entered was 5 and the second number entered was 11.

54.  Suppose you entered "9 7" as the input for the program. What would the final line of output from the program look like?

a.     11 5

b.     7 9

c.     9 7

d.     5 11

Use the following code segment to answer questions 55 through 58.

void ducs( int n , int m ) ;

 

main()

{

int x = 5, int y = 7 ;

ducs( x , y ) ;

printf( "%d %d\n" , x , y ) ;

ducs( x , y ) ;

}

void ducs( int a , int b )

{

int c ;

a *= 2 ;

b *= 2 ;

c = a ;

a = b ;

b = c ;

}

55.  What value does c have at the end of the first call to ducs?

a.     5

b.     7

c.     10

d.     14

56.  Which of the following is the correct output from the program?

a.     5 7

b.     10 14

c.     7 5

d.     14 10

57.  What is the final value of the variable x?

a.     5

b.     7

c.     20

d.     28

58.  What value does b have at the end of the second call to ducs?

a.     10

b.     14

c.     20

d.     28

Use the following code segment to answer questions 59 through 62.

float titania( float thisbe , float pyramus ) ;

int puck( float *lysander , float *hermia ) ;

 

main()

{

float x = 1.3 ,float y = 3.0 ;

float z = 9, float *px ;

float *py , float *pz ;

 

px = &x ;

py = &y ;

pz = &z ;

 

z = titania( x , y ) ;

if ( puck( px , py ) )

printf( "%f %f %f\n" , x , y , z ) ;

else

printf( "%f %f %f\n" , z , y , x ) ;

printf( "%f %f\n" , z , *pz ) ;

}

 

float titania( float demetrius , float helena )

{

return demetrius * helena ;

}

 

int puck( float *lysander , float *hermia )

{

int bottom ;

 

bottom = *lysander ;

*lysander = *hermia ;

*hermia = bottom ;

 

return ( (*lysander) > (*hermia) ) ;

}

59.  What is the final value for the variable z?

a.     3.9

b.     1.3

c.     3.0

d.     9.0

60.  What is the final value for the variable y?

a.     1.3

b.     3.0

c.     3.9

d.     1.0

61.  Which of the following is the correct output from the first printf statement executed by the program?

a.     3.000000 3.900000

b.     1.300000 3.000000 3.900000

c.     3.000000 1.000000 3.900000

d.     3.000000 1.300000 3.900000

62.  Which of the following is the correct output from the last printf statement executed by the program?

a.     3.900000 -2017374568

b.     segmentation fault

c.     3.900000 3.900000

d.     bus error

 

63.  Write a for loop that can replace the following while loop. [1 mark]

i = 0;

while(i < 10) {

printf(%d\n, i);

i++;

}

 

64.  Write a function that receives 2 floats as arguments and returns the average of the 2 floats. [2 marks]

 

65.  #include <stdio.h> [2 marks]

int getChoice(void);

void processChoice(int);

void main(void)

{

int choice;

choice = getChoice();

while ( choice != 4 ) {

processChoice( choice );

choice = getChoice();

}

}

int getChoice(void)

{

int choice;

do {

printf("1. Deposit\n");

printf("2. Withdraw\n");

printf("3. Check balance\n");

printf("4. Quit\n");

printf("==> Your choice? ");

scanf("%d", &choice);

} while ( choice < 1 || choice > 3 );

return choice;

}

void processChoice( int choice )

{

switch ( choice ) {

case 1:

printf( "Depositing...\n" );

break;

case 2:

printf( "Withdrawing...\n" );

break;

case 3:

printf( "Getting balance...\n" );

break;

}

}

What is the output from the processChoice

function if the user inputs a 3?

 

The user cannot quit this program. Why

not?

 

 

 

 

To fix this, change

 

 

 

 

 

 


 


Birla Institute of Technology & Science, Pilani

First Semester 2007-2008

Comprehensive Examination

PART-2

 
Course No. :BITSG644

Course Title :Development & Use of Computer Software

Duration :1 Hr Date:08/12/2007

 

 

Q1 What is software engineering? 5 marks

 

Q2 What are the attributes of good software? 5 marks

 

Q3 What are the key challenges facing software engineering? 5 marks

 

Q4 Differentiate between 10 marks

a.   Evolutionary development And Formal systems development

b.   Reuse-oriented and Incremental Development


 

 

 

 


( 0 Votes )

Add comment


Security code
Refresh

Earning:   Approval pending.
You are here: PAPER Birla Institute of Technology (BIT Mesra) 2007 B.E Development & Use of Computer Software - Question Paper