11-30-2010, 06:30 AM
Question No: 1 ( Marks: 1 ) - Please choose one
[FONT="]What is the output of the following statement? [/FONT]
[FONT="] int i = 2.5; do { cout i * 2; } while (i > 3 && i < 10); [/FONT]
(a) 510
(b) 5
© 48
(d) error
Question No: 2 ( Marks: 1 ) - Please choose one
[FONT="]What does !(7) evaluate to in decimal where ! is a NOT operator?[/FONT]
(a) 7
(b) 8
© 9
(d) 10
Question No: 3 ( Marks: 1 ) - Please choose one
[FONT="]The condition in while loop may contain logical expression but not relational expression.[/FONT]
(a) [FONT="]True[/FONT]
(b) [FONT="]False[/FONT]
Question No: 4 ( Marks: 1 ) - Please choose one
[FONT="]Searching is easier when an array is already sorted[/FONT]
(a) [FONT="]True[/FONT]
(b) [FONT="]False[/FONT]
Question No: 5 ( Marks: 1 ) - Please choose one
[FONT="]If an array has 100 elements, what is allowable range of subscripts?[/FONT]
(a) [FONT="]0 - 99[/FONT]
(b) [FONT="]1 - 99[/FONT]
© [FONT="]0 - 100[/FONT]
(d) [FONT="]1 - 100[/FONT]
Question No: 6 ( Marks: 1 ) - Please choose one
[FONT="]What will be the value of ‘a’ and ‘b’ after executing the following statements?[/FONT]
[FONT="]a = 3;[/FONT]
[FONT="]b = a++;[/FONT]
(a) 3, 4
(b) 4, 4
© 3, 3
(d) 4, 3
Question No: 7 ( Marks: 1 ) - Please choose one
[FONT="]What will be the correct syntax to initialize all elements of two-dimensional array to value 0?[/FONT]
(a) [FONT="]int arr[2][3] = {0,0} ;[/FONT]
(b) [FONT="]int arr[2][3] = {{0},{0}} ;[/FONT]
© [FONT="]int arr[2][3] = {0},{0} ;[/FONT]
(d) [FONT="]int arr[2][3] = {0} ; [/FONT]
Question No: 8 ( Marks: 1 ) - Please choose one
[FONT="]Which of the following function[/FONT][FONT="]returns the size of a string variable?[/FONT]
(a) [FONT="]strlength()[/FONT]
(b) [FONT="]stringlen()[/FONT]
© [FONT="]strlen()[/FONT]
(d) [FONT="]strLength()[/FONT]
Question No: 9 ( Marks: 1 ) - Please choose one
[FONT="]What will be the range of numbers generated by function rand () % 9?[/FONT]
(a) [FONT="]0 to 9[/FONT]
(b) [FONT="]1 to 9[/FONT]
© [FONT="]0 to 8[/FONT]
(d) [FONT="]1 to 8[/FONT]
Question No: 11 ( Marks: 1 ) - Please choose one
[FONT="]Computer can understand only machine language code.[/FONT]
© [FONT="]True[/FONT]
(d) [FONT="]False[/FONT]
Question No: 13 ( Marks: 1 ) - Please choose one
[FONT="]What does 5 ^ 6 , evaluate to in decimal where ‘^’ is Exclusive OR operator?[/FONT]
(a) [FONT="]True[/FONT]
(b) [FONT="]False[/FONT]
[FONT="]Detail:-[/FONT]
[FONT="]It mean [/FONT]
[FONT="]5 = 0[/FONT][FONT="]101[/FONT]
[FONT="]6 = 0110[/FONT]
[FONT="]5 ^ 6 = 0011[/FONT]
[FONT="]If both input is same then the output is 0 and if different then output is 1[/FONT]
Question No: 14 ( Marks: 1 ) - Please choose one
[FONT="]If the file is not properly closed in the program, the program ____________.[/FONT]
(a) [FONT="]Terminate normally[/FONT]
(b) [FONT="]Indicate Runtime error[/FONT]
© [FONT="]Indicate Compile time error[/FONT]
(d) [FONT="]Crashes[/FONT]
Question No: 15 ( Marks: 1 ) - Please choose one
[FONT="]Which of the following header file include string conversion functions?[/FONT]
(a) [FONT="]string.h[/FONT]
(b) [FONT="]stdlib.h[/FONT]
© [FONT="]ctype.h[/FONT]
(d) [FONT="]sconvert.h[/FONT]
Question No: 16 ( Marks: 1 ) - Please choose one
[FONT="]In Program commenting the code liberally is[/FONT]
[FONT="]Solution:- [/FONT]
[FONT="]It need to be self-contained and understandable. Comments should be placed liberally. The comments should explain the logic, not the mechanics. Try to avoid fancy programming.[/FONT]
Question No: 17 ( Marks: 1 )
[FONT="]Which header file must be included while handling files?[/FONT]
[FONT="]Solution:- [/FONT]
Include <fstream.h>
Question No: 18 ( Marks: 1 )
[FONT="]What is meant by C++ statement: [/FONT][FONT="]const int *ptr = &x; [/FONT]
[FONT="]Solution:-[/FONT]
ptr is a pointer to data of type const int type. And to assign the address of x to pointer ptr
Question No: 19 ( Marks: 2 )
[FONT="]What is a truth Table?[/FONT]
[FONT="]Solution:-[/FONT]
[FONT="]We know the concept of truth table. The truth tables are very important. These are still a tool available for analyzing logical expressions. We will read logic design in future, which is actually to do with chips and gate. We find it difficult to evaluate a complicated logical expression. Sometimes the logic becomes extremely complicated so that even writing it as a simple syntax statement in any language[/FONT].
Question No: 20 ( Marks: 3 )
(1) [FONT="]An array [/FONT]day[FONT="] is declared as: [/FONT][FONT="]int day[] = {1, 2, 3, 4, 5, 6, 7};[/FONT]
[FONT="] How many elements does array 'day' has? [/FONT]
[FONT="]Solution:-[/FONT]
[FONT="]7 elements[/FONT]
(2) [FONT="]If the declaration is changed as: [/FONT][FONT="]int day[7] = {1, 2, 3, 4, 5, 6, 7};[/FONT]
[FONT="] How many elements does array 'day' has? [/FONT]
[FONT="]Solution:-[/FONT]
[FONT="]7 elements[/FONT]
Question No: 21 ( Marks: 5 )
[FONT="]What are similarities and differences between Structures and Unions?[/FONT]
[FONT="]In structures, we have different data members and all of these have their own memory space. In union, the memory location is same while the first data member is one name for that memory location. However, the 2[/FONT][FONT="]nd [/FONT][FONT="]data member is another name for the same location and so on. Consider the above union (i.e. intOrChar) that contains an integer and a character as data members. What will be the size of this union? The answer is the very simple. The union will be allocated the memory equal to that of the largest size data member. If the int occupies four bytes on our system and char occupies one byte, the union intOrChar will occupy four bytes[/FONT]
Question No: 22 ( Marks: 10 )
Write a void function( ); that takes integer numbers from the user and then displays the sum of odd and even numbers entered by the user. Your program should terminate if user enters a negative number
Solution:-
[FONT="]What is the output of the following statement? [/FONT]
[FONT="] int i = 2.5; do { cout i * 2; } while (i > 3 && i < 10); [/FONT]
(a) 510
(b) 5
© 48
(d) error
Question No: 2 ( Marks: 1 ) - Please choose one
[FONT="]What does !(7) evaluate to in decimal where ! is a NOT operator?[/FONT]
(a) 7
(b) 8
© 9
(d) 10
Question No: 3 ( Marks: 1 ) - Please choose one
[FONT="]The condition in while loop may contain logical expression but not relational expression.[/FONT]
(a) [FONT="]True[/FONT]
(b) [FONT="]False[/FONT]
Question No: 4 ( Marks: 1 ) - Please choose one
[FONT="]Searching is easier when an array is already sorted[/FONT]
(a) [FONT="]True[/FONT]
(b) [FONT="]False[/FONT]
Question No: 5 ( Marks: 1 ) - Please choose one
[FONT="]If an array has 100 elements, what is allowable range of subscripts?[/FONT]
(a) [FONT="]0 - 99[/FONT]
(b) [FONT="]1 - 99[/FONT]
© [FONT="]0 - 100[/FONT]
(d) [FONT="]1 - 100[/FONT]
Question No: 6 ( Marks: 1 ) - Please choose one
[FONT="]What will be the value of ‘a’ and ‘b’ after executing the following statements?[/FONT]
[FONT="]a = 3;[/FONT]
[FONT="]b = a++;[/FONT]
(a) 3, 4
(b) 4, 4
© 3, 3
(d) 4, 3
Question No: 7 ( Marks: 1 ) - Please choose one
[FONT="]What will be the correct syntax to initialize all elements of two-dimensional array to value 0?[/FONT]
(a) [FONT="]int arr[2][3] = {0,0} ;[/FONT]
(b) [FONT="]int arr[2][3] = {{0},{0}} ;[/FONT]
© [FONT="]int arr[2][3] = {0},{0} ;[/FONT]
(d) [FONT="]int arr[2][3] = {0} ; [/FONT]
Question No: 8 ( Marks: 1 ) - Please choose one
[FONT="]Which of the following function[/FONT][FONT="]returns the size of a string variable?[/FONT]
(a) [FONT="]strlength()[/FONT]
(b) [FONT="]stringlen()[/FONT]
© [FONT="]strlen()[/FONT]
(d) [FONT="]strLength()[/FONT]
Question No: 9 ( Marks: 1 ) - Please choose one
[FONT="]What will be the range of numbers generated by function rand () % 9?[/FONT]
(a) [FONT="]0 to 9[/FONT]
(b) [FONT="]1 to 9[/FONT]
© [FONT="]0 to 8[/FONT]
(d) [FONT="]1 to 8[/FONT]
Question No: 11 ( Marks: 1 ) - Please choose one
[FONT="]Computer can understand only machine language code.[/FONT]
© [FONT="]True[/FONT]
(d) [FONT="]False[/FONT]
Question No: 13 ( Marks: 1 ) - Please choose one
[FONT="]What does 5 ^ 6 , evaluate to in decimal where ‘^’ is Exclusive OR operator?[/FONT]
(a) [FONT="]True[/FONT]
(b) [FONT="]False[/FONT]
[FONT="]Detail:-[/FONT]
[FONT="]It mean [/FONT]
[FONT="]5 = 0[/FONT][FONT="]101[/FONT]
[FONT="]6 = 0110[/FONT]
[FONT="]5 ^ 6 = 0011[/FONT]
[FONT="]If both input is same then the output is 0 and if different then output is 1[/FONT]
Question No: 14 ( Marks: 1 ) - Please choose one
[FONT="]If the file is not properly closed in the program, the program ____________.[/FONT]
(a) [FONT="]Terminate normally[/FONT]
(b) [FONT="]Indicate Runtime error[/FONT]
© [FONT="]Indicate Compile time error[/FONT]
(d) [FONT="]Crashes[/FONT]
Question No: 15 ( Marks: 1 ) - Please choose one
[FONT="]Which of the following header file include string conversion functions?[/FONT]
(a) [FONT="]string.h[/FONT]
(b) [FONT="]stdlib.h[/FONT]
© [FONT="]ctype.h[/FONT]
(d) [FONT="]sconvert.h[/FONT]
Question No: 16 ( Marks: 1 ) - Please choose one
[FONT="]In Program commenting the code liberally is[/FONT]
[FONT="]Solution:- [/FONT]
[FONT="]It need to be self-contained and understandable. Comments should be placed liberally. The comments should explain the logic, not the mechanics. Try to avoid fancy programming.[/FONT]
Question No: 17 ( Marks: 1 )
[FONT="]Which header file must be included while handling files?[/FONT]
[FONT="]Solution:- [/FONT]
Include <fstream.h>
Question No: 18 ( Marks: 1 )
[FONT="]What is meant by C++ statement: [/FONT][FONT="]const int *ptr = &x; [/FONT]
[FONT="]Solution:-[/FONT]
ptr is a pointer to data of type const int type. And to assign the address of x to pointer ptr
Question No: 19 ( Marks: 2 )
[FONT="]What is a truth Table?[/FONT]
[FONT="]Solution:-[/FONT]
[FONT="]We know the concept of truth table. The truth tables are very important. These are still a tool available for analyzing logical expressions. We will read logic design in future, which is actually to do with chips and gate. We find it difficult to evaluate a complicated logical expression. Sometimes the logic becomes extremely complicated so that even writing it as a simple syntax statement in any language[/FONT].
Question No: 20 ( Marks: 3 )
(1) [FONT="]An array [/FONT]day[FONT="] is declared as: [/FONT][FONT="]int day[] = {1, 2, 3, 4, 5, 6, 7};[/FONT]
[FONT="] How many elements does array 'day' has? [/FONT]
[FONT="]Solution:-[/FONT]
[FONT="]7 elements[/FONT]
(2) [FONT="]If the declaration is changed as: [/FONT][FONT="]int day[7] = {1, 2, 3, 4, 5, 6, 7};[/FONT]
[FONT="] How many elements does array 'day' has? [/FONT]
[FONT="]Solution:-[/FONT]
[FONT="]7 elements[/FONT]
Question No: 21 ( Marks: 5 )
[FONT="]What are similarities and differences between Structures and Unions?[/FONT]
[FONT="]In structures, we have different data members and all of these have their own memory space. In union, the memory location is same while the first data member is one name for that memory location. However, the 2[/FONT][FONT="]nd [/FONT][FONT="]data member is another name for the same location and so on. Consider the above union (i.e. intOrChar) that contains an integer and a character as data members. What will be the size of this union? The answer is the very simple. The union will be allocated the memory equal to that of the largest size data member. If the int occupies four bytes on our system and char occupies one byte, the union intOrChar will occupy four bytes[/FONT]
Question No: 22 ( Marks: 10 )
Write a void function( ); that takes integer numbers from the user and then displays the sum of odd and even numbers entered by the user. Your program should terminate if user enters a negative number
Solution:-
Code:
#include<iostream.h>
#include<conio.h>
void function(void);
main()
{
function();
getche();
}
void function(void)
{
int n[5];
for(int i=0; i<=5; i++)
{
cout <<"Enter Element = ";
cin >>n[i];
}
cout <<"\nODD Inputs are = \n";
for(int i=0; i<=5; i++)
{
if(n[i]%2==0)
{
cout <<n[i]<<endl;
}
}
cout <<"\nEVEN Inputs are = \n";
for(int i=0; i<=5; i++)
{
if(n[i]%2==1)
{
cout <<n[i]<<endl;
}
}
}