1. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        printf("%d\t",sizeof(6.5));
        printf("%d\t",sizeof(90000));
        printf("%d",sizeof('A'));
        return 0;
    }

    A
    4 2 1

    B
    8 2 1

    C
    4 4 1

    D
    8 4 2

    Note: By default data type of numeric constants is: 6.5 : double 90000: long int 'A': char In C size of data type varies from compiler to compiler. In TURBO C 3.0 (16 bit compilers) size of: double is 8 byte Long int is 4 byte Character constant is 2 byte (size of char data type is one byte) In TURBO C 4.5 or Linux GCC compilers (32 bit compilers) size of: double is 8 byte long int is 8 byte Character constant is 2 byte
    1. Report
  2. Question: Consider on following declaring of enum. (i) enum cricket {Gambhir,Smith,Sehwag}c; (ii) enum cricket {Gambhir,Smith,Sehwag}; (iii)enum {Gambhir,Smith=-5,Sehwag}c; (iv)enum c {Gambhir,Smith,Sehwag}; Choose correct one:

    A
    Only (i) is correct declaration

    B
    Only (i) and (ii) is correct declaration

    C
    Only (i) and (iii) are correct declaration

    D
    All four are correct declaration

    E
    Only (i),(ii) and are correct declaration

    Note: <b> Syntax of enum data type is:</b> <blockquote class="quote"> enum [<tag_name>]{ <enum_constanat_name> [=<integer_ value>], … } [<var_name>,…] </blockquote> <b>Note:</b> [] : Represents optional . <>: Represents any valid c identifierAuthor:
    1. Report
  3. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        signed x;
        unsigned y;
        x = 10 +- 10u + 10u +- 10;
        y = x;
        if(x==y)
             printf("%d %d",x,y);
        else if(x!=y)
             printf("%u  %u",x,y);
        return 0;
    }

    A
    0 0

    B
    65536 -10

    C
    0 65536

    D
    65536 0

    E
    Compilation error

    Note: Consider on the expression: x = 10 +- 10u + 10u +- 10; 10: It is signed integer constant. 10u: It is unsigned integer constant. X: It is signed integer variable. In any binary operation of dissimilar data type for example: a + b Lower data type operand always automatically type casted into the operand of higher data type before performing the operation and result will be higher data type. As we know operators enjoy higher precedence than binary operators. So our expression is: x = 10 + (-10u) + 10u + (-10); = 10 + -10 + 10 + (-10); = 0 Note: Signed is higher data type than unsigned int. So, Corresponding signed value of unsigned 10u is +10 [/b]Author:[/b]
    1. Report
  4. Question: Which of the following is not modifier of data type in c?

    A
    extern

    B
    interrupt

    C
    huge

    D
    register

    E
    All are modifiers of data type

    Note: na
    1. Report
  5. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        double num=5.2;
        int  var=5;
        printf(\"%d\\t\",sizeof(!num));
        printf(\"%d\\t\",sizeof(var=15/2));
        printf(\"%d\",var);
        return 0;
    }

    A
    4 2 7

    B
    4 4 5

    C
    2 2 5

    D
    2 4 7

    E
    8 2 7

    Note: sizeof(Expr) operator always returns the an integer value which represents the size of the final value of the expression expr. Consider on the following expression: !num =!5.2 =0 0 is int type integer constant and it size is 2 by in TURBO C 3.0 compiler and 4 in the TURBO C 4.5 and Linux GCC compilers. Consider on the following expression: var = 15/2 => var = 7 => 7 7 is int type integer constant. Any expression which is evaluated inside the sizeof operator its scope always will be within the sizeof operator. So value of variable var will remain 5 in the printf statement.
    1. Report
  6. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        const int *p;
        int a=10;
        p=&a;
        printf("%d",*p);
        return 0;
    }

    A
    0

    B
    10

    C
    Garbage value

    D
    Any memory address

    E
    Error: Cannot modify const object

    Note: In the following declaration const int *p; p can keep address of constant integer.
    1. Report
  7. Question: Consider on following declaration: (i)short i=10; (ii) static i=10; (iii) unsigned i=10; (iv) const i=10; Choose correct one:

    A
    Only (iv) is incorrect

    B
    Only (ii) and (iv) are incorrect

    C
    Only (ii),(iii) and (iv) are correct

    D
    Only (iii) is correct

    E
    All are correct declaration

    Note: Default data type of above all declaration is int.
    1. Report
  8. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        int a= sizeof(signed) +sizeof(unsigned);
        int b=sizeof(const)+sizeof(volatile);
        printf("%d",a+++b);
        return 0;
    }

    A
    10

    B
    9

    C
    8

    D
    Error: Cannot find size of modifiers

    E
    Error: Undefined operator +++

    Note: Default data type of signed, unsigned, const and volatile is int. In turbo c 3.0 size of int is two byte. So, a = 4 and b =4 Now, a+++b = a++ + b = 4 + 4 //due to post increment operator. =8 Note: In turbo c 4.5 and Linux gcc compiler size of int is 4 byte so your out will be 16
    1. Report
  9. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        int a= sizeof(signed) +sizeof(unsigned);
        int b=sizeof(const)+sizeof(volatile);
        printf("%d",a+++b);
        return 0;
    }

    A
    10

    B
    9

    C
    8

    D
    Error: Cannot find size of modifiers

    E
    Error: Undefined operator +++

    Note: Turbo C++ 3.0: 8 Turbo C ++4.5: 8 Linux GCC: 16 Visual C++: 16 Default data type of signed, unsigned, const and volatile is int. In turbo c 3.0 size of int is two byte. So, a = 4 and b =4 Now, a+++b = a++ + b = 4 + 4 //due to post increment operator. =8 Note: In turbo c 4.5 and Linux gcc compiler size of int is 4 byte so your out will be 16
    1. Report
  10. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        signed x,a;
        unsigned y,b;
        a=(signed)10u;
        b=(unsigned)-10;
        y = (signed)10u + (unsigned)-10;
        x = y;
        printf("%d  %u\t",a,b);
        if(x==y)
             printf("%d %d",x,y);
        else if(x!=y)
             printf("%u  %u",x,y);
        return 0;
    }

    A
    10 -10 0 0

    B
    10 -10 65516 -10

    C
    10 -10 10 -10

    D
    10 65526 0 0

    E
    Compilation error

    Note: Turbo C++ 3.0: 10 65526 0 0 Turbo C ++4.5: 10 65526 0 0 Linux GCC: 10 4294967286 0 0 Visual C++: 10 4294967286 0 0 a=(signed)10u; signed value of 10u is +10 so, a=10 b=(unsigned)-10; unsigned value of -10 is : MAX_VALUE_OF_UNSIGNED_INT – 10 + 1 In turbo c 3.0 complier max value of unsigned int is 65535 So, b = 65526 y = (signed)10u + (unsigned)-10; = 10 + 65526 = 65536 = 0 (Since 65536 is beyond the range of unsigned int. zero is its corresponding cyclic vlaue) X = y = 0
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd