knoowgle logo
HOME
TOPICS
CONTRIBUTE ADVERTISE
T & C
KNOOWGLE

C-Programing Sample test 7

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

    int f1()
    {
            int i,j;
            for(i=0,j=0;i<321;i++)
                    if(i%111==0) j++;
            if (j==3) return true; else return false;
    }

    int main()
    {
            if ( f1() && ! f1() ) 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

    int f1()
    {
            char s[4]="abc";
            char *p;
            p=s; p+=2;
            if (*p=='c') return true; else return false;
    }

    int main()
    {
            if ( f1() > 0 ) 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()
    {
            int i=3;
            short j=0;
            while (i != 2) {i--;j++;};
            if (j) return true; else return false;
    }

    int main()
    {
            if ( f1() || false ) 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

    int f1()
    {
            char s[4] = "123";
            if (s[1]=='2') return true; else return false;
    }

    int main()
    {
            if ( f1() && ! 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 p2(char *s1, char *s2)
    {
            int flag=0;
            if (strlen(s1)==strlen(s2))
            { while ((*s1==*s2) && (*s1)) {s1++; s2++;}
            flag=(*s1==NULL);}
            return (flag);
    }

    int f1()
    {
            if (p2("AB","AB")) return true; else return
    false;
    }

    int main()
    {
            if ( f1() || true ) 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