Programming Fundamentals
Programming Fundamentals
TIME ALLOWED:
ONE HOUR FOURTY FIVE MINUTES (1 ~).
15. Which of the following is not the classification of computers based on application?
A). Electronic Computers
B). Analog Computers
C). Digital Computers
D). Hybrid Computers
16. Which of the following registers is used to keep track of address of the memory location where the next
instruction is located?
A). Memory address register
B). Memory data register
C). Instruction register
D). Program counter
17. One millisecond is
A). 1 second
B). 10th of a seconds
C). 1000th of a seconds
D). 10000th of a seconds
18. A physical connection between the microprocessor memory and other parts of the microcomputer is known
~s
A). Path
B). Address bus
C). Route
D). All of the above
19. What is the size ofwchar t in C++?
A). 2
B). 4
C). 2 or 4
D). based on the number of bits in the system
20. Pick the odd one out
A). array type
B). character type
C). boolean type
D). integer type
21. Which datatype is used to represent the absence of parameters?
A). int
B). short
C). void
D). float
22. What does a escape code represent?
A). alert
B). backslash
C). tab
D). form feed
23. Which type is best suited to represent the logical values?
A). integer
B). boolean
C). character
7 else
8 return q;
9 }
10 main()
11 (
12 int a = 5, b = 10;
13 int k;
14 bool x = true;
15 bool y =f(a, b);
16 k =((a * B). + (x + y));
17 cout« k;
18 }
A). 33
B). 62
C). 52
D). none of the mentioned
33. What is the value of p?
1 #include <iostream>
2 using namespace std;
3 int main()
4 {
5 intp;
6 bool a = true;
7 bool b =false;
8 int x = 10;
9 inty = 5;
10 P = ((x I y. + (a + b));
11 cout «p;
12 return 0;
13 }
A). 0
B). 16
C). 12
D). 2
34. Evaluate the following
(false && true) II false II true
A). 0
B). 1
C). false
D). none of the mentioned
35. How many characters are specified in the ASCII scheme?
A). 64
B). 128
C). 256
D). none of the mentioned
46. Which of these expressions will return true if the input integer v is a power of two?
A). (v I (v + 1)) == 0;
B). (v·& (v - 1)) == 0;
C). (v I (v + I)) == 0;
D). (v & (v - 1)) == 0;
47. What is the value of the following 8-bit integer after all statements are executed?
int x = 1;
x=x« 7;
x=x» 7;
A). 1
B). -1
C). 127
D). Implementation defined
48. Which of these expressions will make the rightmost set bit zero in an input integer x?
A). x = x I (x-I)
B).x=x&(x-l)
C). x = x I (x+ 1)
D). x = x & (x+ 1)
49. What will be the output of this program?
1 #include <iostream>
2 using namespace std;
3 int main()
4 {
5 int a = 8;
6 cout« "ANDing integer 'a' with 'true' :"« a && true;
7 return 0;
8 }
A). ANDing integer 'a' with 'true' :8
B). ANDing integer 'a' with 'true' :0
C). ANDing integer 'a' with 'true' : 1
D). None of the mentioned
50. What will be output of this program?
1 #include <iostream>
2 using namespace std;
3 int main()
4 {
5 int i = 3;
6 il1t I = i / -2;
7 il1t Ii = i % -2;
8 cout « I « k;
9 return 0;
10 }
A). compile time error
B). -1 1
C). 1 -1
D). implementation defined
51. What will be output of this function?
1 int main( )
2 {
3 register int i = 1;
4 int *ptr = &i;
5 cout « *ptr;
6 return 0;
7 }
A). 0
B). 1
C). Compi ler error may be possible
D). Runtime error may be possible
52. WhiCh of the following is not one of the sizes of the floating point types?
A). short float
B). float
C). long double
D). double
53. Which of the following is a valid floating point literal?
A). f287.333
B). F287.333
C). 287.e2
D). 287.3 .e2
54. What is the range of the floating point numbers?
A). -3.4E+38 to +3.4E+38
B). -3.4E+38 to +3.4E+34
C). -3.4E+38 to +3.4E+36
D). -3.4E+38 to +3.4E+32
55. Which of three sizes of floating point types should be used when extended precision is required?
A). float
B). double
C). long double
D). extended float
56. What is the output of this program?
1 #inclllde <iomanip>
2 #include <iostream>
3 using namespace std;
4 int main()
5 (
6 cout « setprecision(17);
7 double d = 0.1;
8 COlit « d « endl;
9 return 0;
10 }
A). 0.11
B). 0.10000000000000001
C). 0.100001
D). compile time error
57. What is the output of the following program?
1 #inclllde <iostream>
2 using namespace std;
3 int main()
4 {
5 float i = 123.0f;
6 cout « i « endl,'
7 return 0,'
8 }
A). 123.00
B). 1.23
C). 123
D). compile time error
58. What is the output of this program?
1 #include <iostream>
2 using Ilamespace std;
3 int main()
4 {
5 float/1 = 0.5;
6 double 12 = 0.5;
7 i/ (/1 = 0.5j)
8 cout« "equal";
9 else
10 cout« "not equal";
11 return 0;
12 }
A). equal
B). not equal
C). compile time error
D). runtime error
59. Which is correct with respect to size of the datatypes?
A). char> int <float
B). int < char> float
C). char < int < float
D). double < char> int
60. What is the output of the following program?
1 #include <iostream>
2 using namespace sId;
3 int mllill( )
4 {
5 int num = Ox20 + 020 + 20;
6 cout« sizeo/(num.«'n';
7 return 0;
8 }
A). 2
B). 4
C). Depends on compiler.
D). garbage
61. Arrange the size of the data type from lower to higher value in this program.
1 #include <iostream>
2 using namespace std;
3 int main()
4 {
5 char y = 'a';
6 int x = 10;
7 float z = 10.1;
8 cout «sizeo/(char);
9 cout « sizeo/Ont);
10 cout «sizeo/(float);
11 return 0;
12 }
A). 20
B). compile time error
7 {
8 cout «green« red« blue« white« yel/ow« pink;
9 return 0;
10 }
A). 0123456
B). 1111111
C). compile time error
D). runtime error
A). 012
B). 123
C). compile time error
D). runtime.:.' error
72. What is outpUl of the this program?
1 #include <iostream>
2 using namespace std;
3 int main( )
4 {
5 int i;
6 enum month {
7 JAN= 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
8 },"
9 for (i = MAR; i <= NOV; i++)
10 cout« i;
11 return 0;
12 }
A). 0123456789101 1
B). 12345()789101112
C). 34567891011
D). 123456789
17 }
A). 2035655065
B). 2035655035
C). 2035635065
D). none of the mentioned
78. Can two functions declare variables (non statiC). with the same name.
A). No
B). Yes
C). Yes, but not a very efficient way to write programs.
D). No, it gives a runtime error.
B). 123456789
C). 0
D). error
81. Identify the incorrect statements.
int var = 10;
int *ptr = & (var + 1); //statement 1
int *ptr2 = &var; //statement 2
&var = 40; //statement 3
A). Statement 1 and 2 are wrong.
B). Statement 2 and 3 are wrong.
C). Statement I and 3 are wrong
D). All the three are wrong.
85. Which one of the following is not a possible state for a pointer.
A). hold the address of the specific object
B). point one past the end of an object
C). zero
D). point to a type
89. What is the index number of the last element of an array with 9 elements?
A). 9
B). 8
C). 0
D). Progmll1mer-defined
B). array[ I J;
C). array(2);
D). array:
93. What will be the output of this program?
1 #inc/ude <stdio.h>
2 using nllme~pace std;
3 int arrllylll = {1200, 200, 2300,1230, 1543};
4 lnt lIrrlly21l = {12, 14, 16, 18, 20};
5 lnt lemp, result = 0;
6 lnt IIwin()
7 {
8 j;jj' (temp = 0,' temp < 5; temp++. {
9 result += arrayl{temp};
10 )
11 j(n' (temp = 0; temp < 4; temp++. {
12 result += array2{temp};
13 /
14 ('out « result;
15 n:lUrn 0;
16 )
A). 6553
B). 6533
C). 6522
D). 12200
94. What will be tile output of the this program?
1 #indude <stdio.h>
2 US/ilg nllmespace std;
3 int lHain ()
4 {
5 inll1rrayll = to, 2, 4, 6, 7, 5,3};
6 int 11, result = 0;
7 fur (n = 0 ; n < 8; n++) {
8 result += array{n};
9 J
(
10 I.:ouf «result;
11 I'e/urn 0;
12 }
A). 25
B). 26
C). 27
D). None ur the mentioned
95. Constants are "dso called as
A). const
B). preprocessor
C). literal s
D). none of the mentioned
96. What are the parts of the literal constants?
A). 4
B). 5
C). address 0 f arr
D). 7
8 p++; *p = 20;
9 p = &nllmbers/2); *p = 30;
10 p = numbers + 3; *p = 40;
11 P = numbers; *(p + 4) = 50;
12 .IlJr (int II = 0; II < 5; 11++)
13 CDitl « numbers/n)« ", ";
14 f'eHlI'n 0;
15 }
A). 10, 20, 30, 40, 50
B). 1020304050
C). compile error
D). runtime error