Review of Class Xi
Total Page:16
File Type:pdf, Size:1020Kb
![Review of Class Xi](http://data.docslib.org/img/c9b22246b5723f341bd9a151ce779848-1.webp)
REVIEW OF CLASS XI Short questions: PART- I(SOLVED) a.i.1. What are literals in C++.How many types of literals you know in C++. Ans Literals (also known as constants) are expressions with a fixed value. These are the data items whose value never change during execution of the program. It is often referred as literals. Five types of literals are there in C++ Integer literals , Floating point literals, character literal, string literals, Boolean values . a.i.2. What is the difference between ‘a’ and “a”? Ans ‘a’ is simply a character constant that occupies one byte in memory while “a” is string literal that stores a+ \0 character in memory that means it stores 2bytes in memory. a.i.3. What is the size of the following :’\n’, ”hello\t”, ”Saima”, ’ \’. Ans ’\n’ : 1 byte ,it is an escape sequence ”hello\t” : 7bytes (hello takes 5 bytes ,\t is an esacpe sequence takes 1byte , one for null character) ”Saima” : 6bytes( 5 bytes for saima and one for null charcter ) ’ \’ : 1 byte ,it is character constant . a.i.4. Predict the output or error(s) for the following:
void main() { int const p=5; p = p+1 ; cout<
a.i.9. What do you understand by the term type casting? Ans Converting an expression of a given type into another type is known as type-casting. Example int x=9 Float y= float (x) ;//now x is float not int 1. What is the difference between while and do while. Ans while do while It is an entry controlled loop It is an exit controlled loop. If the condition is true then only it If the condition is false then also it executes the body of the loop. gets executed at least once. while loop : Do
while (condition) {
{ Statements;
Statements; }while(condition); }
2. What is the difference between exit() and break. Ans exit() brings the control out of the program It is mainly used in menu driven programs and for error checking condition where we don’t want to check for any other condition if the invalid input is entered . break : is used in loops and so on, and stops the current code block before running onto the next portion of code. (If used in a for loop that is to run 20 times for example, if break is used on the 8th iteration, the for loops ends and moves on to run whatever code comes next).
3. What is the wrong with the following code #include
wrong code corrected code int k = 10; int k = 10; do ; do //semicolon is removed { { cout << cout << k++; while ( k < 50) ; while k < 50 ; // while must have braces } }
5. Name the header file(s) that shall be needed for successful compilation of the following C++ code : void main( ) { char Text[40]; strcpy(Text,”AISSCE”); puts(Text); }
Ans strcpy() is defined in
#include 7. In the following program, if the value of N given by the user is 20, what maximum and minimum values the program could possibly display? 2 #include 8. In the following C++ program what is the expected value of Myscore from Options (i) to (iv) given below. Justify your answer. #include 12. Declare a structure customer to store the following data : Customer name ( string), phoneno(integer),age(integer) and use address in the structure. Ans struct customer { char name[20]; int phoneno; int age; address a; }cust; 13. Find the syntax error in the following code: Main() { Struct employee { int empno; char Ename[20]; float Basic,hra,da ; double Netpay; } ; emp1,emp2 } Ans Terminator should come after emp1 and emp2 i.e main() { struct employee { int empno; char ename[20]; float basic,hra,da ; double netpay; } emp1,emp2; } 14. write a macro for finding maximum number and print the maxvalue . Ans // function macro #include int main() { int x=10, y; y= getmax(x,2); cout << y << endl; cout << getmax(70,x) << endl; return 0; } Output: 10 70 15. Write a program to create a function to accept student data and pass this structure by reference to function where student is the structure with the fields as name and class[4](characterarray),age and rollno as an integer. Ans. #include char name [20]; int age; int roll; char clas[4]; }; void getdata(student &st); void main() { student stud; clrscr(); getdata(stud); cout<<”\nname is “< void getdata( student & st) { cout<<”name “; cin>> st.name; cout<<”age “; cin>> st.age; cout<<”roll “; cin>> st.roll; cout<<”class “; cin>> st.clas; } //end of function PART -II HOTS (HIGH ORDER THINKING QUESTIONS): a.i.1. What would be contents of following after array initialization? int A[5]={3,8 ,9} Ans: 3 8 9 0 0 a.i.2. Suggest storage class for following variables ½ each 1. a normal variable. 2. very heavily used variable. 3. a variable that should retain its value after function is over. 4. a variable that spanes multiple files. 5. a variable global in one & not available in another file. a.i.3. Find the output of the following code: main( ) { int n[3][3] = { 2, 4, 3, 6, 8, 5, 3, 5, 1 } ; cout<< n[2][1] ; } a.i.4. Find the output of the following code: main( ) { int twod[ ][ ] = { 2, 4, 6, 8 } ; cout<< twod ; } a.i.5. Point out the errors, if any, in the following program segments: (a) /* mixed has some char and some int values */ int char mixed[100] ; main( ) { int a[10], i ; for ( i = 1 ; i <= 10 ; i++ ) { cin>> a[i] ; cin>> a[i] ; } } a.i.6. What is the difference between Object Oriented Programming and Procedural Programming? Ans: a.i.7. Write the names of the header files to which the following belong: (i) frexp() (ii) isalnum() a.i.8. Write the names of the header files to which the following belong: 1 (i) strcmp() (ii) fabs() a.i.9. Find the output of the following program: #include #include #include #agaSbarr (d) In the following program, if the value of Guess entered by the user is 65, what will be the expected output(s) from the following options (i), (ii), (iii) and (iv)? #include (b) Write the names of the header files to which the following belong: (i) frexp() (ii) isalnum() Ans (i) math.h (ii) ctype.h (c) Find the output of the following program: #include (c) Rewrite the following program after removing the syntactical errors (if any). Underline each correction. #include [iostream.h] #include [stdio.h] class Employee { int EmpId=901; char EName [20] ; public Employee(){} void Joining() {cin>>EmpId; gets (EName);} void List () {cout< #include >Charge;} void Show{cout<