1. Question: Which of the following is integral data type?

    A
    void

    B
    char

    C
    float

    D
    double

    E
    None of these

    Note: In c char is integral data type. It stores the ASCII value of any character constant.
    1. Report
  2. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    int main(){
        volatile int a=11;
        printf("%d",a);
        return 0;
    }

    A
    11

    B
    Garbage

    C
    -2

    D
    We cannot predict

    E
    Compilation error

    Note: We cannot predict the value of volatile variable because its value can be changed by any microprocessor interrupt.
    1. Report
  3. Question: What is the range of signed int data type in that compiler in which size of int is two byte?

    A
    -255 to 255

    B
    -32767 to 32767

    C
    -32768 to 32768

    D
    -32767 to 32768

    E
    -32768 to 32767

    Note: Note: Size of int is always equal to word length of micro preprocessor in which your compiler has based.
    1. Report
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
Copyright © 2024. Powered by Intellect Software Ltd