C Expressions and Control Flow questions

Q35

GATE CS 2016 CS-1C ProgrammingMCQ2 marks−2/3 if wrong
What will be the output of the following C program?
void count(int n){
    static int d=1;

    printf("%d ", n);
    printf("%d ", d);
    d++;
    if(n>1) count(n-1);
    printf("%d ", d);
}

void main(){
    count(3);
}
Show answer without attempting

Answer: A

Q45

GATE CS 2016 CS-1C ProgrammingNAT2 marks
The attributes of three arithmetic operators in some programming language are given below.
OperatorPrecedenceAssociativityArity
++HighLeftBinary
−-MediumRightBinary
∗*LowLeftBinary
The value of the expression 2−5+1−7∗32-5+1-7*3 in this language is ________.
Show answer without attempting

Answer: 9.0

Q35

GATE CS 2016 CS-2C ProgrammingMCQ2 marks−2/3 if wrong
The following function computes XYX^Y for positive integers XX and YY.
int exp(int X, int Y) {
    int res = 1, a = X, b = Y;
    while ( b != 0 ){
        if ( b%2 == 0) { a = a*a; b = b/2; }
        else { res = res*a; b = b-1; }
    }
    return res;
}
Which one of the following conditions is TRUE before every iteration of the loop?
Show answer without attempting

Answer: C

0/30 correct0 marks

Related topics in C Programming