0% found this document useful (0 votes)
5 views

Programming Fundamentals

Uploaded by

afatsawobright2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Programming Fundamentals

Uploaded by

afatsawobright2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

STUDENT ID: ................................................................ .. SiGN ........................................ .

(All rights reserved)


BSc. INFORMATION TECHNOLOGY, FIRST SEMESTER EXAMINATION, 2022/2023

DEPARTMENT OF DISTANCE EDUCATION


CSIT 105: PROGRAMMING FUNDAMENTALS (3 CREDITS)
INSTRUCTIONS:
ANSWER ALL QUESTION IN THE QUESTION PAPER. CIRCLE THE CORRECT ANSWER WITH INK

TIME ALLOWED:
ONE HOUR FOURTY FIVE MINUTES (1 ~).

1. Mnemonic memory trick is used in which of the following language?


A). Machine language
B). Assembly language
C). High level language
D). None of above
2. Which of the following is called low level languages?
A). Machine language
B). Assembly language
C). Both of the above
D). None of above
3. A compiler is a translating program which
A). Translates instruction of a high-level language into machine language.
B). Translates entire source program into machine language program.
C). It is not involved in the program's execution.
D). All of above
4. Which statement is valid about interpreter?
A). It translates one instruction at a time
B). Object code is saved for future use
C). Repeated interpretation is not necessary
D). All of above
5. Which is a limitation of high level language?
A). Lower efficiency
B). Machine dependence
C). machine level coding
D). None of above

EXAMINER: Michael K. Kolugu Page 1 of20


STUDENT ID: ................................................................. . SiGN ........................................ .

6. The first electronic computer in the world was


A). UNIVAC
B). EDVAC
C). ENIAC
D). All of above
7. The most commonly used standard data code to represent alphabetical, numerical and punctuation characters
used in electronic data processing system is called
A). ASCII
B). EBCDIC
C). BCD
D). All of above
8. 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
9. Microprocessors can be used to make
A). Computers
B). Digital systems
C). Calculators
D). All of above
10. Which of the following require large computers memory?
A). Imaging
B). Graphics
C). Voice
D). All of Above
11. The basic operation(s) performed by a computer are
A). Arithmetic operation
B). Logical operation
C). Storage and retrieval
D). All the above
12. The two major types of computer chips are
A). External memory chip
B). Primary memory chip
C). Microprocessor chip
D). Both band c
13. Microprocessors as switching devices are for which generation computers
A). First Generation
B). Second Generation
C). Third Generation
D). Fourth Generation
14. Which of the following is not a type of Software
A). System Software
B). Application Software
C). Utility Software
D). Entertainment Software

EXAMINER: Michael K. Kolugu Page 2 of20


STUDENT 10: .................................................................. SiGN ..................................•......

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

EXAMINER: Michael K. Kolugu Page 3 of20


STUDENT 10: ................................................................. . SiGN ........................................ .

D). all of the mentioned


24. Identify the user-defined types from the following?
A). enumeration
B). classes
C). both a and b
D). int
25. Is boo 1 a fundamental datatype in C++
A). Yes
B). No, it is a typedef of unsigned char
C). No, it is an enum of {false,true}
D). No, it is expanded from macros
26. Find the odd one out:
A). std::vector<int>
B). std: :vector<short>
C). std::vector<long>
D). std::vector<bool>
27. What is the value of the bool?
1. bool is_int(789.54)
A). True
B). False
28. What happens when a null pointer is converted into bool?
A). An error is flagged
B). bool value evaluates to true
C). bool val ue evaluates to false
D). the statement is ignored
29. Which of the following statements are false?
A). bool can have two values and can be used to express logical expressions.
B). bool cannot be used as the type of the result of the function.
C). bool can be converted into integers implicitly
D). a bool val ue can be used in arithemetic expressions.
30. For what values of the expression is an if-statement block not executed?
A). 0 and all negative values
B). 0 and-l
C). 0
D). 0, all negative values, all positive values except 1
31. Which of the two operators ++ and - work for the bool datatype in C++?
A). None
B). ++
C).-
D). Both
32. What is the output of the following program?
1 #include <iostream>
2 using namespace std;
3 int f(int p, int q)
4 (
5 if(p > q)
6 returnp;

EXAMINER: Michael K. Kolugu Page 4 of20


STUDENT 10: ................................................................. . SiGN ........................................ .

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

EXAMINER: Michael K. Kolugu Page 5 of20


STUDENT 10: ................................................................ .. SiGN ....................................... ..

36. Select the right option.


Given the variables p, q are of char type and r, s, t are of int type
1. t = (r * s) / (r + s);
2. t = (p * q) / (r + s);
A). 1 is true but 2 is false
B). 1 is false and 2 is true
C). both 1 and 2 are true
D). both 1 and 2 are false
37. Which of the following belongs to the set of character types?
A). char
B). wchar_t
C). only a
D). both a and b
38. What will be the output of this program?
1 #include <iostream>
2 using namespace std;
3 int main()
4 {
5 char c = 74;
6 cout« c;
7 return 0;
8 }
A). A
B).N
C). J
D). I
39. What is the output of this program?
1 #include <stdio.h>
2 int main()
3
4 char a = '\012';
5
6 printj("%d", a);
7 return 0;
8 }
A). Compiler error
B). 12
C). 10
D). Empty
40. In C++, what is the sign of character data type by default?
A). Signed
B). Unsigned
C). Implementation dependent
D). None of these
41. Is the size of character literals different in C and C++?
A). Implementation defined
B). Can't say

EXAMINER: Michael K. Kolugu Page 6 of20


STUDENT 10: ................................................................ .. SiGN ........................................ .

C). Yes, they are different


D). No, they are not different
42. Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char. return?
A). 4
B). 1
C). Implementation dependent
D). Machi ne dependent
43. What constant defined in <c1imits> header returns the number of bits in a char?
A). CHAR_SIZE
B). SIZE_CHAR
C). BIT_CHAR
D). CHAR_BIT
44. The size_t integer type in C++ is?
A). Unsigned integer of at least 64 bits
B). Signed integer of at least 16 bits
C). Unsigned integer of at least 16 bits
D). Signed integer of at least 64 bits
45. What is the output of the following program?
1 #include <iostream>
2 using namespace std;
3 int main()
4 (
5 intx=-I;
6 unsigned int y = 2;
7
8 If(x > y) {
9 cout « "x is greater";
10 } else {
11 cout« fry is greater";
12 }
13 }
A). x is greater
B). y is greater
C). Implementation defined
D). Arbitrary

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

EXAMINER: Michael K. Kolugu Page 7 of20


STUDENT 10: ................................................................. . SiGN ........................................ .

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

EXAMINER: Michael K. Kolugu Page 8 of20


STUDENT 10: ................................................................ .. SiGN ........................................ .

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 }

EXAMINER: Michael K. Kolugu Page 9 of20


STUDENT 10: ................................................................. . SiGN ........................................ .

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';

EXAMINER: Mil~hael K. Kolugu Page 10 of20


STUDENT 10: .................................................................. SiGN ........................................ .

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). float> int < char


B). int < char < float
C). char < int < float
D). none of the mentioned
62. Which of the following will not return a value?
A). null
B). void
C). empty
D). free
63. have the return type void?
A). all functions
B). constructors
C). destructors
D). none of the mentioned
64. What does the following statement mean?
void a;
A). variable a is of type void
B). a is an object of type void
C). declares a variable with value a
D). flags an error
65. Choose the incorrect option
A). void is used when the function does not return a value.
B). void is also used when the value of a pointer is null.
C). void is used as the base type for pointers to objects of unknown type.
D). void is a special fundamental type.
66. What is the output of this program?
1 #include <iostream>
2 using namespace std;
3 int mllin( )
4 {
5 voicia=10,b=10;
6 int c;
7 c= II + b;
8 cout« c;
9 return 0;
10 }

A). 20
B). compile time error

EXAMINER: Michael K. Kolugu Page 11 of20


STUDENT 10: ................................................................. . SiGN ........................................ .

C). runtime error


D). none of the mentioned
67. Which variable does equals in size with enum variable?
A). int variable
B). float variable
C). string variable
D). none of the mentioned
68. What is the output of this program?
1 #include <iostream>
2 using namespace std;
3 enum cat {
4 temp = 7
5 };
6 int main( )
7 {
8 illt age = 14;
9 age /= temp;
10 cout« "Ifyou were cat, you would be "« age« endl;
11 return 0;
12 }

A). If you were cat, you would be 5


B). If you were cat, you would be 2
C). If you were cat, you would be 7
D). none of the mentioned
69. What is the output of this program?
1 #inc/ude <iostream>
2 using namespace std;
3 enum test {
4 A =32, B, C
5 };
6 int main( )
7 {
8 cout «A «B« C;
9 return 0;
10 }
A). 323334
B). 323232
C). 323130
D). none of the mentioned
70. What is the output of this program?
1 #inc/ude <iostream>
2 using namespace std;
3 enu m colour {
4 green, red, blue, white, yellow, pink
5 };
6 int main( )

EXAMINER: Michael K. Kolugu Page 12 of 20


STUDENT 10: ................................................................. . SiGN ........................................ .

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

71. What is the output of this program?


1 #include <iostream>
2 using namespace std;
3 int main( )
4 {
5 enum channel {star, sony, zee};
6 enum symbol {hash, star};
7 inti = 0;
8 /01' (i = star; i <= zee; i++. (
9 print/("%d ", i);
10 }
11 return 0;
12 }

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

EXAMINER: Michael K. Kolugu Page 13 of20


STUDENT 10: .................................................................. SiGN ........................................ .

73. Choose the correct option.


1 extern jut i;
2 int i;
A). both 1 and 2 declare i
B). 1 declares the variable i and 2 defines i
C). 1 declares and defines i, 2 declares i
D). 1 declares i,2 declares and defines i
74. Pick the right option
Statement 1: A definition is also a declaration.
Statement 2: An identifier can be declared just once.
A). Statement 1 is true, Statement 2 is false.
B). Statement 2 is true, Statement 1 is false.
C). Both are false.
D). Both are true.
75. Which of the given statements are false.
1 extern inl June;
2 extern intfunc2(int,int);
3 int/unc2(int,int);
4 extern class /00;
A). 3 and 4 only
B). 2 and 3 only
C). only 4
D). 2, 3 and 4-
76. Pick the right option
Statement I: Global values are not initialized by the stream.
Statement 2: Local values are implicitly initialized to O.
A). Statement 1 is true, Statement 2 is false.
B). Statement 2 is true, Statement 1 is false.
C). Both are false.
D). Both are true.
77. What is the output of this program?
1 #indude <iostream>
2 using namespace std;
3 int g = 100;
4 int main()
5 {
6 iut a;
7
8 int b;
9 b = 20;
10 a = 35;
11 g = 65;
12 cout « b « a« g;
13
14 a = 50;
15 C(Hlt« a« g;
16 return 0;

EXAMINER: Michael K. Kolugu Page 14 of20


STUDENT 10: ................................................................ .. SiGN ........................................ .

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.

79. What is the Olltput of this program?


1 #indude <;ostream>
2 using namespace std;
3 void uddprint()
4 {
5 sialic int s = 1;
6 s++;
7 cout «s;
8 }
9 int Jnain()
10 (
11 uJdprint( );
12 mldprint();
13 (illdprint( );
14 return 0;
15 }
A). 234
B). 111
C). 123
0).235
80. What is the output of this program?
1 #indude <iostream>
2 using namespace sId;
3 int main( )
4 (
5 inla = 10;
6 ~l({I < 10) {
7 j(Jr (i = 0; i < 10; i++)
8 cout« i;
9 }
10 else {
11 cout« i;
12 j
13 return 0;
14 }
A).01234S()789

EXAMINER: Michael K. Kolugu Page 15 of20


STUDENT 10: ................................................................. . SiGN ........................................ .

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.

82. What does the following statement mean?


int (*fp)(char*)
A). pointer 10 a pointer
B). pointer to an array of chars
C). pointer to function taking a char* argument and returns an int
D). function taking a char* argument and returning a pointer to int

83. The operator used for dereferencing or indirection is _ _


A). *
B). &
C). ->
D). -»

84. Choose the right option


string~: x~ y;
A). x is a pointer to a string, y is a string
B). y is a pointer to a string, x is a string
C). both x ~lI1d yare pointer to string types
D). none 0 r the mentioned

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

86. Which of the following is illegal?


A). int *ip:
B). string s. *sp = 0;
C). int i; double* dp = &i;
D). int *pi = 0;

125. What will happen in this code?


int a = IOU, b = 200;

EXAMINER: lVlichacl K. Kolugu Page 16 of20


STUDENT 10: ................................................................ .. SIGN ........................................ .

int *p = &a, *q = &b;


p=q;
A). b is assigned to a
B). p now points to b
C). a is assigned to b
D). q now points to a

87. What is the OULput of this program?


1 #indm.le <iostream>
2 using namespace std;
3 int illiiin( )
4 {
5 illt a = 5, b = 10, c = 15;
6 int *arr[ ] = {&a, &b, &c};
7 COlit «arr[I];
8 n..'turn 0;
9
A). 5
B). 10
C). 15
D). it wi II return some random number

88. Which of the following correctly declares an array?


A). int array[ I 0];
B). int arr,t)';
C). array { IO};
D). array arcay[ 10];

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

90. What is a array?


A). An array is a series of elements of the same type in contiguous memory locations
B). An array is a series of element
C). An array is a series of elements of the same type placed in non-contiguous memory locations
D). None ur the mentioned
91. Which of the i~)llowing accesses the seventh element stored in array?
A). arrayL6j;
B). arrayL71;
C). array(7);
D). array;
92. Which of the foilowing gives the memory address of the first element in array?
A). array [0 \;

EXAMINER: 1\-1i,:had K. Kolugu Page 17 of20


STUDENT 10: ................................................................ .. SiGN ........................................ .

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?

EXAMINER: lVtiduacl K. Kolugu Page 18 of20


STUDENT 10: ................................................................ .. SiGN ........................................ .

A). integer numerals


B). floating-point numerals
C). strings and boolean values
D). all of tile mentioned
97. How the const,mts are declared?
A). const k~yword
B). #definc preprocessor
C). both a and b
D). None uf the mentioned
98. What is the output of this program?
1 #inc!ude <iostream>
2 using l'1amespace std;
3 il1l /iUlin( )
4 {
5 illtconst p = 5;
6 cout «++p;
7 return 0;
8 }
A). 5
B). 6
C). Error
D). None or the mentioned
99. What is the output of this program?
1 #inc!ude <iostream>
2 using namespace std;
3 inl main()
4 {
5 ifd arr[J = {4, 5, 6, 7};
6 ilil *p = (arr + 1);
7 cuuf « arr;
8 relurn 0;
9 }

A). 4
B). 5
C). address 0 f arr
D). 7

100. What is the uutput of this program?


1 #indade <iostream>
2 using l'1amespace std;
3 int 11;;ain ( )
4 {
5 in!numbers/5J;
6 in! * p;
7 p = numbers; *p = 10;

EXAMINER: lVii~hacl K. Kolugu Page 19 of20


, #

STUDENT 10: ................................................................ .. SiGN ........................................ .

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

EXAMINER: Midwcl K. Kolugu Page 20 of20

You might also like