C Programming Practice - Test 4

20 Questions | Total Attempts: 59

SettingsSettingsSettings
C Programming Quizzes & Trivia

. Dear Learner, This Assessment consists of questions to test your understanding on - C Programming You may attempt the same and clarify doubts in WP Group. / With your Faculty Member Regards, Team SHIVAM


Questions and Answers
  • 1. 
    What is the output? main() { char val[] = {‘a’,’b’,’c’,’\n’,’c’,’\0’}; char *p, *val1, *val2; p = &val[3]; val1 = val; val2 = val; printf(“%d”, ++*p + ++*val1 – 32); }
    • A. 

      Non-portable pointer conversion

    • B. 

      122

    • C. 

      97

    • D. 

      77

  • 2. 
    What is the output? main() { char *arr = “abc defg”, *x; x = arr; while( *arr != ‘\0’ ) ++*arr++; printf(“%s %s”,arr,x); }
    • A. 

      Compiler error

    • B. 

      No output

    • C. 

      Bcd!efgh

    • D. 

      Abc defg

  • 3. 
    What is the output? main() { char far *ptr1, *ptr2; printf(“%d %d”,sizeof(ptr1),sizeof(ptr2)); }
    • A. 

      2 2

    • B. 

      4 4

    • C. 

      2 4

    • D. 

      4 2

  • 4. 
    What is the output? main() { char family[4][20] = { “jesus”, “ram” , “rahim” , “gurunanak” }; char *temp; int count ; temp = family[1]; family[1] = family[2]; // Lvalue required for this line family[2] = temp; // Lvalue required for this line for(count = 0 ;count
    • A. 

      Non portable pointer conversion

    • B. 

      Compilation error-Lvalue required

    • C. 

      jesus rahim ram gurunanak

    • D. 

      Jesus ram rahim gurunanak

  • 5. 
    Int main() { struct Some Name { int size = 5; char tips[] = "LEARN"; }; struct SomeName ss; printf("\n %d %s",ss.size,ss.tips); return 0; }
    • A. 

      Structure cannot be defined inside main()

    • B. 

      5 LEARN

    • C. 

      Structure member can not be initialized

    • D. 

      Structure can not have char[]

  • 6. 
    Main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }
    • A. 

      1

    • B. 

      0

    • C. 

      Compiler error

    • D. 

      None of these

  • 7. 
    Main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }
    • A. 

      2 5 5

    • B. 

      A b c

    • C. 

      Compiler error

    • D. 

      None of these

  • 8. 
    Void main() { int array[]={10,20,30,40}; printf("%d",-2[array]); }
    • A. 

      -30

    • B. 

      60

    • C. 

      30

    • D. 

      Garbage Value

  • 9. 
    Main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }
    • A. 

      Mmmm aaaa nnnn

    • B. 

      Compiler error

    • C. 

      Mmm aaa nnn

    • D. 

      Garbage Value

  • 10. 
    What is the the output ? main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j
    • A. 

      2 2 2 2 2 3 4 6 5

    • B. 

      2 2 2 2 2 2 3 4 6 5

    • C. 

      2 2 2 2 2 2 4 6 5

    • D. 

      2 2 2 2 2 2 3 4 6

  • 11. 
    What is the output ? main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }
    • A. 

      0 0 1 3 1

    • B. 

      0 1 3 1 0

    • C. 

      1 3 1 0 0

    • D. 

      0 0 1 1 3

  • 12. 
    What is the output ? void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }
    • A. 

      3 3

    • B. 

      6 3

    • C. 

      6 6

    • D. 

      3 6

  • 13. 
    Which of the following doesn’t match an array
    • A. 

      Static allocation

    • B. 

      Successive memory

    • C. 

      Heterogeneity

    • D. 

      Fixed size

  • 14. 
    Which of the following character is appended with a string
    • A. 

      ‘\r’

    • B. 

      ‘\n’

    • C. 

      ‘\t’

    • D. 

      ‘\0’

  • 15. 
    What is the output ? #include #include int main() { char *str = "x"; char c = 'x'; char ary[1]; ary[0] = c; printf("%d %d", strlen(str), strlen(ary)); return 0; }
    • A. 

      1 1

    • B. 

      2 1

    • C. 

      2 2

    • D. 

      1 (undefined value)

  • 16. 
    What will be the output? void main() { char c=125; c=c+10; printf(“%d”,c); }
    • A. 

      -121

    • B. 

      -8

    • C. 

      135

    • D. 

      Compiler Error

  • 17. 
    Void main() { int a[]={0,1,2,3,4}; int * p[]={a,a+1,a+2,a+3.a+4}; printf(“%d”,*(*p)); }
    • A. 

      A

    • B. 

      A+4

    • C. 

      0

    • D. 

      4

  • 18. 
    An array is a
    • A. 

      ADT

    • B. 

      Basic datatype

    • C. 

      Derived datatype

    • D. 

      User defined datatype

  • 19. 
    The array name indicates
    • A. 

      Const pointer

    • B. 

      Pointer to constant

    • C. 

      Generic pointer

  • 20. 
    The difference between a character array and string is
    • A. 

      Appended ‘\0’ in string

    • B. 

      Appended ‘\0’ in character array

    • C. 

      %s can’t be used for character array

    • D. 

      %s can be used for both

Back to Top Back to top