knoowgle logo
HOME
TOPICS
CONTRIBUTE ADVERTISE
T & C
KNOOWGLE

C-Programing Sample test 1

  1. What will the value of x be after the following steps are executed
  2. char * message;
    message = (char *) malloc (sizeof(char) * 10);
    message = "hello";
    x = strlen (message);

    (a)  0
    (b)  5
    (c)  10
    (d)  The statements would not compile.


  3. (int i=0; i <256; i++2)
  4. printf("%d", i);

    How many times will this loop execute?

    (a)  256
    (b)  128
    (c)  127
    (d)  Infinitely.


  5. What is the output of the program?
  6. main()
    {
      int i = 5;
      i = ! i>3;
      printf(”%d”,i);

    (a)  5
    (b)  0
    (c)  3
    (d)  processor dependent.

  7. What is the output of the following
  8. main()
    {
       int x[10] = {1,2,3,4,5,6,7,8,9,10};
       int *p = x;
       int *q = &x[9];
       printf ("%d", q-p+1);
    }

    (a) 0
    (b) 19
    (c) 10
    (d) Error

  9.          main()
  10. {
    int a = 0;
    int *p = &a;
    free(p);
    printf(”%d”, a);
    }

    (a) Works fine
    (b) Free can’t be used for p
    (c) Compiler Error
    (d) In printf we should use *p instead of i



    Click here for answers

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