NOVEMBER TEST SOLUTIONS

http://www.facebook.com/GmacpsItClub
CLASS XII NOVEMBER 1 TEST SOLUTION UPLOADED TO

http://quadd.co.cc

CLASS XI SOLUTION UPLOADED TO

Students are requested to submit answers to Class XI November Test questions by commenting on this post. Best answers will be compiled in official solutions with your names.
(LAST DATE: 04/11/12 17:00 Hrs) Thank you.

5 comments:

  1. 1.Actual Arguments: Actual arguments are the real arguments that are passed/used during the function call.
    The value of these arguments gets copied to the formal arguments.

    Formal arguments: Formal arguments act as local arguments that are passed/used only during the function definition.
    Formal arguments are the copy of actual arguments.

    C++ CODE TO ILLUSTRATE BOTH:
    #include
    void sum(int,int);
    void main()
    {
    sum(a,b); //'a' and 'b' are the actual arguments
    }
    void sum(int x,int y)/* 'x' and 'y' are formal arguments */
    {
    int z=x+y;
    cout<<z;
    }

    ReplyDelete
  2. 1. b)
    (i) exp() -- math.h (header file)
    (ii) strcmp() -- string.h(header file)

    c) Void means empty or null. Void data type is used as a return data type for those functions that do not return any value to the caller. E.g it is used with main() and user defined functions (No return,No argument) & (No return With argument). In C++ the default return data type is int(integer) so we need a data type that indicates nothing is being returned so, void data type is used to indicate that nothing is being returned to the caller.

    d) Difference between 0,'0','\0' and "0"
    0 - With respect to coding it represents a simple number zero and with respect to output it sometimes represent 'FALSE'. e.g. if we encounter 0 using isdigit() etc then it means answer is false i.e. the entered value is not a digit.
    '0'- It represents a character. Anything written within the single quotes is referred to as a character.
    '\0'- It represents a null character. It occupies space(1byte) and is automatically placed at the end of the string.
    "0"- It represents a string. Anything written within the double quotes is referred to as a string.

    e)
    (i) string.h - It is a header file that contains declarations of in-built functions that operate on C/C++ strings. E.g: strlen(), strcmp() etc. If we want to use these functions we need to include the header file otherwise compiler will not recognize these functions and will generate error.

    (ii) ctype.h - It is a header file that contains declarations of in-built functions the operate on C/C++ characters. E.G. isalpha(), isdigit() etc. For proper functioning of these in-built functions we need to include this header file in order to avoid the errors generated by the compiler.

    (iii) math.h - It is a header file that contains declarations of mathematical in-built functions e.g. pow(),sqrt() etc. We need to include the header file for the reasons mentioned above.

    (iv) conio.h - It is a header file that contains declarations of in-built functions like clrscr().

    f) strcat() appends a string to another string.

    g) Difference between islower() and tolower():
    islower() - This in-built function is used to check whether the given character/string is in lower case or not. The function returns non zero if the given character/string is in lowercase otherwise returns zero which is equivalent to false.
    e.g. cout<<islower('A')
    Output: 0

    tolower()- This in-built function is used to convert the given string/character to lower case if in uppercase otherwise returns same string i.e. output.
    e.g. cout<<tolower('A')
    Output: a

    ReplyDelete
  3. 2.
    (a) (i) float a[+40]; - Invalid because the size of array must be an integer value or integer constant without any sign.
    (ii) int num[0-10]; - Invalid because the size of the array must be an integer value or integer constant without any sign. Here range is given so this declaration is also invalid.
    (iii) double[50] -Invalid because the sentence terminator is missing so compiler will give syntax error.
    (iv) amount[50] of float - Invalid because it doesn't follow the correct declaration. Correct : type array-name[size];
    (v) int score[20]; - Valid
    (vi) char name[30]; -Valid
    (vii) float array[5]; - Valid

    (b)
    (i) int x[5]; - 5 elements( int x[0]; ....... int x[4];)
    (ii) double y[10]; - 10elements (double y[0]; ....... double y[9];)
    (iii) char z[18]; - 18elements ( char z[0]; ...... char z[17];)
    (iv) float a[20]; - 20 elements (float a[0]; ..... float a[19];)

    ReplyDelete
  4. 3.
    a) Function Prototyping - A function prototyping is a declaration of the function that tells the program about the type of value returned by the function and the number and type of arguments.

    Syntax: return-data-type name-of-the-function (argument list);
    E.G: void sum(int,int);
    Here void is the return data type
    sum is the function name
    and argument list tells us about the data type of arguments and no. of arguments

    b) Importance of parenthesis: Argument list is enclosed inside the parenthesis. It is a very important part of function prototyping syntax. Compiler generates error if these parenthesis are missing. The argument list enclosed inside parenthesis tells us about the data type and no.of arguments.

    ReplyDelete
  5. 3.
    d) Output:
    Enter two real numbers:2 5.2
    Value of a is:2Value of b is 5.2

    e) Int(Integer) data type is the default data type of a function.

    f) Difference between User defined and in-built functions:
    User Defined functions: These functions are created by the programmer. These functions are created as per the requirements of the program and are not the part of compiler package.
    These functions are of three types:
    (i) No Return No Argument
    (ii)No Return With Argument
    (iii)With Return With Argument
    No need to include any extra header files.

    In-Built functions - These functions are part of compiler package.\ e.g. sqrt() , pow()
    For using these functions in our programs we need to call them in the main and need to include the header files containing their declarations.

    ReplyDelete