0% found this document useful (0 votes)
19 views12 pages

Cs201p LAB 1 and 2 Quiz 1

The document contains a quiz with multiple-choice questions related to programming concepts, specifically in C and C++. It covers topics such as data types, loops, functions, memory allocation, and syntax. Each question includes the correct answer and some explanations or notes from the author regarding the answers.

Uploaded by

hs7811167
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)
19 views12 pages

Cs201p LAB 1 and 2 Quiz 1

The document contains a quiz with multiple-choice questions related to programming concepts, specifically in C and C++. It covers topics such as data types, loops, functions, memory allocation, and syntax. Each question includes the correct answer and some explanations or notes from the author regarding the answers.

Uploaded by

hs7811167
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/ 12

Cs201p Quiz 1 Spring 2022

LAB1 and 2 MCQs


Orange Monkey Team
NOTE:~
SUBJECT mera na hony key natey maine kisi v mcqs key anser confirm
nhe kiye hein but try maine apni best ke hey comment sey dekh ker
correction krli hey but phir bhe koi wrong mily to us mistake ko lazmi
mere video key description main or apny apny groups main inform
krdijiye ga …JAZAKALLAH

1. Identify the invalid option


Int* pi = 0;

2. Word processor is

Application software

3. Each pass through a loop is called a/an

Iteration

4. What is the correct syntax to declare an array of size 10 of int data type?

Int name[10];

5. Which of the following operator is used to access the value of variable pointer to by
a pointer

& operator

6. Analysis is the ____ step in designing a program

ORANGE MONKEY TEAM Page 1


First

7. Paying attention to detail in designing a program is _________.

Necessary

8. Statement in curly braces is

Must

9. The while loop becomes infinite.

When the condition is always true

10. Which of the following function(s) is/are included in stdlib.h header file?

Double atof(const char*nptr), int atol(const char*nptr) ….. 1 and 2 only both

11. If we want to store a string abc in an array str then the size of this array must be at
least

12. Char name[ ]= “Hello world”;


In the above statement a memory of ____ characters will be allocated to the array
name

11
13. Suppose we have declared a two dimensional array multi. To access elements using
pointer we should use referencing like ________.

*multi

14. Which of the following is the correct method to declare an array?

Data,type,array,name,[size]

15. What will be the output of the following code?


INt main(){
Int a(4)={1,2,3,4};
Cout<<a{2};
}

ORANGE MONKEY TEAM Page 2


16. Which of the following two arrays are copy able?

Int a[5]. Int b[5]

17. What will be the output of the following code?


Int main (){
Char str1{} = “Hello”;
Char str2{}=”World!”;
Cout<<strcat (str1,str2);
}

HelloWorld!

18. In C++ using if statement if we want to execute more than one statement then we
have to enclose all statement in ____________

{}

19. What is the output of the following statement?


Int I = 2.5;
Do (cout i*2;)
While (I > 3 && I < 10);

Error

20. Searching is easier when an array is already sorted.

True

21. If an array has 100 elements what is allowable range of subscripts?

0 – 99

22. What will be the value of a and b after executing the following statements?
A = 3; b = a++;

4,3
23. Which of the following function returns the size of a string variable?

ORANGE MONKEY TEAM Page 3


Strlen ( )

24. Computer can understand only machine language code.

True

25. If the file is not properly closed in the program, the program _______.

Terminate normally

26. Which of the following header file include string conversion functions?

String.h

27. The function of cin is

To read data from keyboard

28. IN C/C++ language the header file which is used to perform useful task and
manipulation

Ctype.h

29. The coding of a program is translated into machine language by ________.

Compiler

30. In C/C++ the algebraic expression (b2-4ac)/2a can be written as;

(b*b-4*a*c)/(2*a)

31. The coding of a program is translated into machine language by

Compiler

32. Which of the following expression is correct in C/C++ language?

X=X+3

33. __________ character is used to terminate a string

Null

34. In C++ atoi () function is used to convert __________.

Character string to integer

ORANGE MONKEY TEAM Page 4


35. Which of the following is an example of repetition structure?

While

36. Function declaration is a one-line statement in which we write the return type,
_____ of the function and the ______ of arguments.

Name, Data type

37. What will be the output of the following code?


Int main (){
Int a[4]={1,2,3,4};
Cout<<a[2];}
3
38. If the condition is not mode false in while loop, what will happen?

Local will become infinte

39. In C++ cout is known as ________.

Output stream

40. What will be the output of the following piece of code?


int square(int number){
int result = 0;
result = number *number;
return result;}
int main()
{
Cout<<square(9);
}
81

41. What will be the output of the following code?


Int main(){
Int number[5] = {10,20,30,40,50};
Cout<<(number+3)}
40

42. Which of the following is not a file opening mode?


Ios::trune

ORANGE MONKEY TEAM Page 5


43. Function declaration is a one-line statement in which we write the return type ____
of the function and the __ of argument
Name, Data type

44. In C++, the precise way to declare a pointer is.

Int*ptr;

45. In C++, what is the correct syntax for accessing the fifth element of an array?

A[4]

46. __statement is necessary in switch structure.

Break

47. Normally the float data type is half of the size of ________.

Double

48. A variable declared inside a code block becomes the _____ variable for that block.

Local

49. In C++, all the string manipulation function are defined inside _ header file.

String.h

50. The size variable in the following program is a _ variable


#include<iostream>
-
Int size
-
Int main()
{
-
}

Global

51. What will be the output of the following code?


Int I = 0;
While(i!= 15){

ORANGE MONKEY TEAM Page 6


Cout<<i<<””;
I=i+5;
}

0 5 10

52. Which of the following C++ statements is used take input from the user?

Cin

53. ____________ statement is necessary in switch structure

Break

54. Learning how to program is important because it develops _______ and problem
solving abilities.

Analytical

55. Which of the following option is used when working with complicated expressions in
C++?

()

56. A binary operator has _________ operands

Two

57. Which of the following is the default function calling mechanism of C/C++?

Call by value

58. In C++ which of the following option has the correct meaning of the expression
a<=b?

A is less than or equal to b

59. What will be the output of the following code?

Int i=1;

While(i<10){

If(i%2==0)

ORANGE MONKEY TEAM Page 7


Cout<<i<<” “;

I++;}

2,4,6,8

60. What will be the output of the following code


Int x =15;
Int y =10;
Int z =5;
Cout<<x*x – 4*y*z;

25

61. Which of the following expression is correct C/C++ language?

X=x+3

62. Which of the following is an example of logical operator


&&,||

63. In C/C++, which of the following data type is used to store real numbers?

Float

64. C/C++ has many libraries which contain variables and function names normally
starting with _________.

Underscore

65. The coding of a program is translated into machine language by ______.


Compiler

66. Which of the following option gives the value stored at the address pointed to by the
pointer “ptr”?

*ptr

ORANGE MONKEY TEAM Page 8


LAB 2 Quiz

67. We cannot declare a function as a friend of ________ class

Istream or ostream

68. What will be the output of this given code


#include <iostream>
#include<iomanip>
Using namespace std;
Main( )
{float num = 15.9999;
Cout<<setprecision (2)<<num;}

16
69. Automatic variables are created constantly and destroyed ________.

All the time

70. __________ are a conditional compilation process that is used to replace a piece of
code by its definition in a program

Macros

71. Calloc( ) functions allocates multiple blocks of memory and each block have
_______?

Same size

72. Which of the following header file deals with stream extraction?

Iostream.h

73. Trying to use getch( ) function without including #include<conio.h> header file in
the program is a _______ error

Compilition

74. In C++ the default constructor takes ______.

No arguments

75. In C++ the name of the______ is the same as that of a class with a preceding tilde (~)
sign

ORANGE MONKEY TEAM Page 9


Destructor

76. Which of the following option returns the state of end of file?

Cin.eof();

77. If the memory In the free store is not sufficient enough to fulfill the request,
malloc() function returns ________.

NULL

78. In C/C++ language memory at runtime is allocated from _______.

Free store(heap)

79. When overloading assignment (=) operator which of the following syntax is correct?

Void operator = (const string &s);

80. What will be output of the following code


#include<iostream>
#include<iomanip>
Using namespace std;
Main()
{
Int num = 7
Cout<<setfil(“”) <<setw(4)<<num<<enl;}

***7
81. For overloading minus (.) operator which member operator function will be
correct?

Complex operator – (Complex c)

82. In C++ which operator is used for memory allocation?

new

83. The statement char arr[10] is an example of a type of _____ memory allocation

Static

84. Which of the following options not a source of the output stream?

ORANGE MONKEY TEAM Page 10


Region in the memory

85. Which is not a preprocessor directive of C language?

#startif

86. In the syntax of the overloaded operator function given below

Complex operator + (Complex &);

What is operator

Keyboard

87. If(day==daysofMonth(*this))
{}
In above code *this refers to;

Current class

88. How many objects are initialized for the class data? Date mydates[10];

10

89. What would be the output of the following statement? C=13%2

90. Which statement about pointer is not true?

Pointer can be void

91. Representing logical depiction of the solution to the problem is known as a _______.

Structure

92. Which statement about manipulator is not true?

It automatically gets that object as parameter passed in to the function

93. Which of the following options not a source of the output stream

screen

ORANGE MONKEY TEAM Page 11


ORANGE MONKEY TEAM Page 12

You might also like