1. Question: What is the notation for following functions?
    1.  int f(int a, float b)
        {
            /* Some code */
        }
    2.  int f(a, b)
        int a; float b;
        {
            /* Some code */
        }

    A
    1. KR Notation 2. ANSI Notation

    B
    1. Pre ANSI C Notation 2. KR Notation

    C
    1. ANSI Notation 2. KR Notation

    D
    1. ANSI Notation 2. Pre ANSI Notation

    Note: Not available
    1. Report
  2. Question: How many times the program will print "IndiaBIX" ?
    #include<stdio.h>
    
    int main()
    {
        printf("IndiaBIX");
        main();
        return 0;
    }

    A
    Infinite times

    B
    32767 times

    C
    65535 times

    D
    Till stack overflows

    Note: Not available
    1. Report
  3. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    void main(){
        int a=5,b=10,c=1;
        if(a&&b>c){
             printf("cquestionbank");
        }
        else{
             break;
        }
    }

    A
    cquestionbank

    B
    It will print nothing

    C
    Run time error

    D
    Compilation error

    E
    None of the above

    Note: Keyword break is not syntactical part of if-else statement. So we cannot use break keyword in if-else statement. This keyword can be use in case of loop or switch case statement. Hence when you will compile above code compiler will show an error message: Misplaced break.
    1. Report
  4. Question: What will be output when you will execute following c code?
    #define True 5==5
    #include<stdio.h>
    void main(){
        if(.001-0.1f)
             printf("David Beckham");
        else if(True)
             printf("Ronaldinho");
        else
            printf("Cristiano Ronaldo");
    }

    A
    David Beckham

    B
    Ronaldinho

    C
    Cristiano Ronaldo

    D
    Warning: Condition is always true

    E
    Warning: Unreachable code

    Note: As we know in c zero represents false and any non-zero number represents true. So in the above code: (0.001 – 0.1f) is not zero so it represents true. So only if clause will execute and it will print: David Beckham on console. But it is bad programming practice to write constant as a condition in if clause. Hence compiler will show a warning message: Condition is always true Since condition is always true, so else clause will never execute. Program control cannot reach at else part. So compiler will show another warning message: Unreachable code
    1. Report
  5. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    void main(){
        int a=100;
        if(a>10)
             printf("M.S. Dhoni");
        else if(a>20)
             printf("M.E.K Hussey");
        else if(a>30)
               printf("A.B. de villiers");
    }

    A
    M.S. Dhoni

    B
    A.B. de villiers

    C
    M.S Dhoni M.E.K Hussey A.B. de Villiers

    D
    Compilation error: More than one conditions are true

    E
    None of the above

    Note: In case of if – if else – if else … Statement if first if clause is true the compiler will never check rest of the if else clause and so on.
    1. Report
  6. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    void main(){
        int x=-1,y=-1;
        if(++x=++y)
             printf("R.T. Ponting");
        else
             printf("C.H. Gayle");
    }

    A
    R.T Ponting

    B
    C.H. Gayle

    C
    Warning: x and y are assigned a value that is never used

    D
    Warning: Condition is always true

    E
    Compilation error

    Note: Consider following statement: ++x=++y As we know ++ is pre increment operator in the above statement. This operator increments the value of any integral variable by one and return that value. After performing pre increments above statement will be: 0=0 In C language it is illegal to assign a constant value to another constant. Left side of = operator must be a container i.e. a variable. So compiler will show an error message: Lvalue required In c if you assign any value to variable but you don’t perform any operator or perform operation only using unary operator on the variable the compiler will show a warning message: Variable is assigned a value that is never
    1. Report
  7. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    void main(){
        if(sizeof(void))
             printf("M. Muralilidaran");
        else
             printf("Harbhajan Singh");
    }

    A
    M. Muralilidaran

    B
    Harbhajan Singh

    C
    Warning: Condition is always false

    D
    Compilation error

    E
    None of the above

    Note: It illegal to find size of void data type using sizeof operator. Because size of void data type is meaning less.
    1. Report
  8. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    void main(){
        if(sizeof(void))
             printf("M. Muralilidaran");
        else
             printf("Harbhajan Singh");
    }

    A
    M. Muralilidaran

    B
    Harbhajan Singh

    C
    Warning: Condition is always false

    D
    Compilation error

    E
    None of the above

    Note: It illegal to find size of void data type using sizeof operator. Because size of void data type is meaning less.
    1. Report
  9. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    void main(){
        int m=5,n=10,q=20;
        if(q/n*m)
             printf("William Gates");
        else
             printf(" Warren Buffet");
             printf(" Carlos Slim Helu");
    }

    A
    William Gates

    B
    Warren Buffet Carlos Slim Helu

    C
    Run time error

    D
    Compilation error

    E
    None of the above

    Note: Consider the following expression: q / n * m In this expression there are two operators. They are: /: Division operator *: Multiplication operator Precedence and associate of each operator is as follow:
    PrecedenceOperatorAssociate
    1/ , *Left to right
    Precedence of both operators is same. Hence associate will decide which operator will execute first. Since Associate is left to right. So / operator will execute then * operator will execute. = q / n * m = 20 / 10 * 5 = 2 * 5 =10 As we know in c zero represents false and any non-zero number represents true. Since 10 is non- zero number so if clause will execute and print: William Gates Since in else clause there is not any opening and closing curly bracket. So compiler will treat only one statement as a else part. Hence last statement i.e. printf(" Carlos Slim Helu"); is not part of if-else statement. So at the end compiler will also print: Carlos Slim Helu So output of above code will be: William Gates Carlos Slim Helu
    1. Report
  10. Question: What will be output when you will execute following c code?
    #include<stdio.h>
    void main(){
        if(!printf("Mukesh Ambani"))
        if(printf(" Lakashmi Mittal"));
    }

    A
    Mukesh Ambani

    B
    Lakashmi Mittal

    C
    It will print nothing

    D
    Mukesh Ambani Lakashmi Mittal

    E
    Compilation error: if statement without body

    Note: Return type of printf function is int. This function return a integral value which is equal to number of characters a printf function will print on console. First of all printf function will: Mukesh Ambani. Since it is printing 13 character so it will return 13. So, !printf("Mukesh Ambani") = !13 = 0 In c language zero represents false. So if(0) is false so next statement which inside the body of first if statement will not execute.
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd