1. 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;
    }
    Choose all that apply:

    A
    4 2 7

    B
    4 4 5

    C
    2 2 5

    D
    2 4 7

    E
    8 2 7

    Note: Turbo C++ 3.0: 2 2 5 Turbo C ++4.5: 2 2 5 Linux GCC: 4 4 5 Visual C++: 4 4 5 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
  2. 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;
    }
    Choose all that apply:

    A
    0

    B
    10

    C
    Garbage value

    D
    Any memory address

    E
    Error: Cannot modify const object

    Note: Turbo C++ 3.0: 10 Turbo C ++4.5: 10 Linux GCC: 10 Visual C++: 10 In the following declaration const int *p; p can keep address of constant integer.
    1. Report
  3. 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: Not available
    1. Report
  4. 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;
    }
    Choose all that apply:

    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
  5. 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;
    }
    Choose all that apply:

    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 compiler 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
  6. Question: What will be output of the following c program?
    #include<stdio.h>
    int main(){
    int goto=5;
    printf("%d",goto);
    return 0;
    }

    A
    5

    B
    10

    C
    20

    D
    Compilation error

    E
    None

    Note: Invalid variable name. goto is keyword in c. variable name cannot be any keyword of c language.
    1. Report
  7. Question: What will be output of the following c program?
    #include<stdio.h>
    int main(){
        int ABC=10;
        printf("%d",abc);
        return 0;
    }

    A
    10

    B
    0

    C
    5

    D
    Compilation error

    E
    None

    Note: Variable name is case sensitive.
    1. Report
  8. Question: What will be output of the following c program?
    #include<stdio.h>
    int main(){
        int printf=12;
        printf("%d",printf);
        return 0;
    }

    A
    12

    B
    0

    C
    5

    D
    Compilation error

    E
    None

    Note: Variable name cannot be pre defined function of included header file.
    1. Report
  9. Question: What will be output of the following c program?
    #include<stdio.h>
    int main(){
        int EOF=12;
        printf("%d",EOF);
        return 0;
    }

    A
    12

    B
    0

    C
    5

    D
    Compilation error

    E
    None

    Note: Variable name cannot be pre defined function of included header file.
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd