MIDTERM EXAMINATION
Spring 2010
CS201- Introduction to Programming (Session - 2)
Ref No: 1348086
Time: 60 min
Marks: 38
Student Info | |
StudentID: | |
Center: | |
ExamDate: |
Question No: 1 ( Marks: 1 ) - Please choose one
► Its remainder
► The number
► Its quotient
► Its divisor
Question No: 2 ( Marks: 1 ) - Please choose one
► (condition ) while; do { statements; };
► { statements; } do-while ();
► while(condition); do { statements; };
► do { statements; } while (condition);
Question No: 3 ( Marks: 1 ) - Please choose one
► double atof(const char *nptr)
► int atoi(const char *nptr)
► char *strcpy ( char *s1, const char *s2)
► 1 and 2 only
Question No: 4 ( Marks: 1 ) - Please choose one
► The compiler will give error
► This may cause a logical error
► No effect on program
► Program stops its execution
Question No: 5 ( Marks: 1 ) - Please choose one
► Return Type
► Function data
► Function arguments
► Function name
Question No: 6 ( Marks: 1 ) - Please choose one
► tellptr()
► write()
► seekg()
► get()
Question No: 7 ( Marks: 1 ) - Please choose one
►3
►4
►5
►7
Question No: 8 ( Marks: 1 ) - Please choose one
► Linux
► Windows
► Unix
► Mac OS
Question No: 9 ( Marks: 1 ) - Please choose one
► 33
► 45
► 9
► 30
Question No: 10 ( Marks: 1 ) - Please choose one
char str[] = “programming”;
► 10
► 11
► 12
► 13
Question No: 11 ( Marks: 1 ) - Please choose one
► char ptr = ’programming’ ;
► char *ptr = “programming” ;
► char *ptr = ‘programming’ ;
► *ptr = “programming” ;
Question No: 12 ( Marks: 1 ) - Please choose one
►x = 1
►x = 3
►x = 7
►x = 2
Question No: 13 ( Marks: 1 ) - Please choose one
►JAVA
►B
►C
►FORTRAN
Question No: 14 ( Marks: 1 ) - Please choose one
►True
►False
Question No: 15 ( Marks: 1 ) - Please choose one
int i, j ;
int x[5] = {2, 3, 4, 8, 9} ;
int *ptr =&x[2];
i = (*ptr)++ ;
j = *ptr++ ;
►i = 5, j = 5
►i = 5, j = 8
►i = 4, j = 8
►i = 5, j = 9
Question No: 16 ( Marks: 1 ) - Please choose one
► reference
► data type
► value
► data
Question No: 17 ( Marks: 2 )
Ans:The “switch” statement is use to slect among multiple alternatives.It uses many if statements to execute a particular case,while “if” statement is use to slect among two alternatives.
Question No: 18 ( Marks: 2 )
Ans:To execute the .exe file properly with latest changes.
Question No: 19 ( Marks: 2 )
Ans:
int matrix[0][0]=2
int matrix[1][0]=2
int matrix[2][0]=2
Question No: 20 ( Marks: 3 )
main(){
int x = 10
const int *ptr = &x ;
*ptr = 5 ;
}
Ans:
Int x=10….No ending semicolon.
*ptr=5 .. Declaring a pointer to constant integer.You can not use this pointer to change the value being pointed to.
Question No: 21 ( Marks: 3 )
Ans:Yes,we use assignment operator,whenever we use objects that allocate memory it is important that assignment operator should be defined for it,otherwise default operator will copy the value of addressed and pointers.
Question No: 22 ( Marks: 5 )
Ans:Binary search algorithm is more efficient than liner algorithem because the arrays are sorted in asending or desending order and we use “devide and conqrer” technique.In binery search each iteration reduces the search by the factor of two but in the linear we have the same number of searches as we have the number of elements.e.g,if we have array of 1000 elements the linear search will take 1000 iterations however binery search will take max 10.
Question No: 23 ( Marks: 5 )
Hint:
Size of char is 1 byte
Size of int is 2 byte
Size of float is 4 byte
#include <iostream.h>
union mytypes_t {
char c;
int i;
float f;
} mytypes;
int main(){
mytypes.c = 'H';
mytypes.i = 15;
cout << sizeof(mytypes)<<endl;
mytypes.i = 15;
mytypes.c = 'H';
cout << sizeof(mytypes)<<endl;
system("PAUSE");
return 0;
}
No comments:
Post a Comment
PLEASE COMMENT ABOUT YOUR VISIT AND MY SITE
Note: Only a member of this blog may post a comment.