1. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    const enum Alpha{
          X,
          Y=5,
          Z
    }p=10;
    int main(){
        enum Alpha a,b;
        a= X;
        b= Z;
        printf("%d",a+b-p); 
        return 0; 
    }

    A
    -4

    B
    -5

    C
    10

    D
    11

    E
    Error: Cannot modify constant object

    Note: Default value of enum constant X is zero and Z = Y + 1 = 5 + 1 = 6 So, a + b – p =0 + 6 -10 = -4
    1. Report
  2. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        char a=250;
        int expr;
        expr= a+ !a + ~a + ++a;
        printf("%d",expr);
        return 0;
    }

    A
    249

    B
    250

    C
    0

    D
    -6

    E
    Compilation error

    Note: char a = 250; 250 is beyond the range of signed char. Its corresponding cyclic value is: -6 So, a = -6 Consider on the expression: expr= a+ !a + ~a + ++a; Operator! , ~ and ++ have equal precedence. And it associative is right to left. So, First ++ operator will perform the operation. So value a will -5 Now, Expr = -5 + !-5 + ~-5 + -5 = -5 + !-5 + 4 - 5 = -5 + 0 + 4 -5 = -6
    1. Report
  3. Question: Consider on order of modifiers in following declaration: (i)char volatile register unsigned c; (ii)volatile register unsigned char c; (iii)register volatile unsigned char c; (iv)unsigned char volatile register c;

    A
    Only (ii) is correct declaration

    B
    Only (i) is correction declaration

    C
    All are incorrect

    D
    All are correct but they are different

    E
    All are correct and same

    Note: Order of modifier of variable in c has not any significant.
    1. Report
  4. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        int a=-5;
        unsigned int b=-5u;
        if(a==b)
             printf("Avatar");
        else
             printf("Alien");
        return 0;
    }

    A
    Avatar

    B
    Alien

    C
    Run time error

    D
    Error: Illegal assignment

    E
    Error: Don’t compare signed no. with unsigned no.

    Note: int a=-5; Here variable a is by default signed int. unsigned int b=-5u; Constant -5u will convert into unsigned int. Its corresponding unsigned int value will be : 65536 – 5 + 1= 65532 So, b = 65532 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. In c signed int is higher data type than unsigned int. So variable b will automatically type casted into signed int. So corresponding signed value of 65532 is -5 Hence, a==b
    1. Report
  5. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    extern enum cricket x;
    int main(){
        printf("%d",x); 
        return 0;
    }
    const enum cricket{
        Taylor,
        Kallis=17,
        Chanderpaul
    }x=Taylor|Kallis&Chanderpaul;

    A
    0

    B
    15

    C
    16

    D
    17

    E
    Compilation error

    Note: Turbo C++ 3.0: 16 Turbo C ++4.5: Compilation error Linux GCC: Compilation error Visual C++: 16 x=Taylor|Kallis&Chanderpaul = 0 | 17 & 18 = 0 |(17 & 18) //& operator enjoy higher precedence than | =0 |16 =16
    1. Report
  6. Question: Which of the following is not derived data type in c?

    A
    Function

    B
    Pointer

    C
    Enumeration

    D
    Array

    E
    All are derived data type

    Note: Enum is primitive data type.
    1. Report
  7. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    enum A{
        x,y=5,
        enum B{
             p=10,q
        }varp;
    }varx;
    
    int main(){
        printf("%d %d",x,varp.q);
        return 0;
    }

    A
    0 11

    B
    5 10

    C
    4 11

    D
    0 10

    E
    Compilation error

    Note: Nesting of enum constant is not possible in c.
    1. Report
  8. Question: Consider on following declaration in c: (i)short const register i=10; (ii)static volatile const int i=10; (iii)unsigned auto long register i=10; (iv)signed extern float i=10.0; Choose the correct one:

    A
    Only (iv)is correct

    B
    Only (ii) and (iv) is correct

    C
    Only (i) and (ii) is correct

    D
    Only (iii) correct

    E
    All are correct declaration

    Note: Option (III) is in correct due to we cannot specify two storage class auto and register in the declaration of any variable. Option (iv) is in correct due to we cannot use signed or unsigned modifiers with float data type. In c float data type by default signed and it cannot be unsigned.
    1. Report
  9. Question: What will be output of the following c program?
    #include<stdio.h>
    int main(){
    long int 1a=5l;
    printf("%ld",1a);
        return 0;
    }

    A
    5

    B
    51

    C
    6

    D
    Compilation error

    E
    None of these

    Note: Invalid variable name. Variable name must star from either alphabet or underscore.
    1. Report
  10. Question: What will be output of the following c program?
    #include<stdio.h>
    int main(){
        int _=5;
        int __=10;
        int ___;
        ___=_+__;
        printf("%i",___);
        return 0;
    }

    A
    5

    B
    10

    C
    15

    D
    Compilation error

    E
    None of these

    Note: Variable name can have only underscore.
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd