knoowgle logo
HOME
TOPICS
CONTRIBUTE ADVERTISE
T & C
KNOOWGLE

C-Programing Sample test 9

  1. What is the output of the Program?
  2. #define true 1
    #define false 0

    int f1()
    {
            int i;
            int v[3]={1,2,3};
            for (i=1; i<3;i++) v[i] = v[i-1] + v[i]*i;
            if (v[2]>8) return true; else return false;
    }

    int main()
    {
            if ( f1() == 0 ) return true;
            else return false;
    }

    (a)  true
    (b)  false
    (b)  Compile error.


  3. What is the output of the Program?
  4. #define true 1
    #define false 0

    #define STR "HAPPY"
    #define MAX 5

    int f1()
    {
            if (strlen(STR)>MAX) return true;
            else return false;
    }

    int main()
    {
            if ( ! f1() ) return true
            else return false;
    }

    (a)  true
    (b)  false
    (b)  Compile error.


  5. What is the output of the Program?
  6. #define true 1
    #define false 0

    int f1()
    {
            struct { int boy,girl;} Joe;
            Joe.boy=true; Joe.girl=!Joe.boy;
            if (Joe.boy || ! Joe.girl) return true; else
    return false;
    }

    int main()
    {
            if ( f1() > 0 ) return true;
            else return false;
    }

    (a)  true
    (b)  false
    (b)  Compile error.

  7. What is the output of the Program?
  8. #define true 1
    #define false 0

    void p3(int *v1, int v2)
    { *v1=v2; v2++; }

    int f1()
    {
            int a=0, b=3;
            p3(&a,b);
            if (a==b) return true; else return false;
    }

    int main()
    {
            if ( ! f1() ) return true;
            else return false;
    }

    (a)  true
    (b)  false
    (b)  Compile error.

  9. What is the output of the following Program?        
    #define true 1
    #define false 0

    int f1()
    {
            if (11/4<11%4) return true; else return false;
    }

    int main()
    {
            if ( f1() && ! f1() ) return true;
             else return false;
    }

    (a)  true
    (b)  false
    (b)  Compile error.




  10. Click here for answers

Google
 
Web www.knoowgle.com
Contributed by: www.knoowgle.com
Copyright 2006 knoowgle.com