c question paper with answers.pdf

3
C ASSESSMENT Mr. SHIVA (BATCH 2 CS/IS) 1) void main() { char *s="\12345s\n"; printf("%d",sizeof(s)); } a) 9 b) 8 c ) 7 d ) 6 2) How do you declare an array of N pointers to functions returning pointers to functions returning pointers to characters? a) char *(*a[N])(); b) char *(*(a[N])())(); c) char *(*(*a[N])())(); d) char *a[N](); 3) main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } a) 5 20 1 b) 5 10 0 c) 0 10 5 d) None 4) #define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } a) 10 5 b) 5 10 c) Compilation Error d) None 5) What is pointer to a pointer? a) Pointer to store address of another pointer. 2) Pointer to store the value of a pointer c) Both pointers store same memory location. 4) None 6) What is a structure ? a ) Array of objects b) Grouping of different data types. C ) Grouping of Similar data types. D) None 7) How can you increase the size of a dynamically allocated array?

Transcript of c question paper with answers.pdf

  • C ASSESSMENT Mr. SHIVA (BATCH 2 CS/IS)

    1)

    void main()

    {

    char *s="\12345s\n";

    printf("%d",sizeof(s));

    }

    a) 9 b) 8 c ) 7 d ) 6

    2) How do you declare an array of N pointers to functions returning pointers to functions returning pointers to

    characters?

    a) char *(*a[N])(); b) char *(*(a[N])())(); c) char *(*(*a[N])())(); d) char *a[N]();

    3) main()

    {

    int x=5;

    printf("%d %d %d\n",x,x2);

    }

    a) 5 20 1 b) 5 10 0 c) 0 10 5 d) None

    4) #define swap1(a,b) a=a+b;b=a-b;a=a-b;

    main()

    {

    int x=5,y=10;

    swap1(x,y);

    printf("%d %d\n",x,y);

    swap2(x,y);

    printf("%d %d\n",x,y);

    }

    int swap2(int a,int b)

    {

    int temp;

    temp=a;

    b=a;

    a=temp;

    return;

    }

    a) 10 5 b) 5 10 c) Compilation Error d) None

    5) What is pointer to a pointer?

    a) Pointer to store address of another pointer. 2) Pointer to store the value of a pointer

    c) Both pointers store same memory location. 4) None

    6) What is a structure ?

    a ) Array of objects b) Grouping of different data types. C ) Grouping of Similar data types. D) None

    7) How can you increase the size of a dynamically allocated array?

  • a) malloc b) calloc c) realloc d) none

    8) What will be the last character in a String ?

    a) 0 b) \0 c) \n d) none

    9) Storage Classes available in C language

    a) 1 b)2 c) 3 d) 4

    10 ) Which function is used to delete the dynamic allocated memory.

    a) Free() b) delete c) remove d) erase

    11) Write a program to compare two strings without using the strcmp() function.

    12) Write a program to create a File and perform read and write operations on it.

    13) Write a program to print the output as follows.

    5 4 3 2 1

    4 3 2 1

    3 2 1

    2 1

    1

    14 ) Write a program to find the Biiggest, Next Biggest and smallest values in a given Single

    Dimension Array.

    15 ) Write a program to sort the Strings in a Array.

    Solutions for C Objectives

    1) d

    2) c

    3) a

    4) a

    5) a

    6) b

  • 7) c

    8) b

    9) d

    10) a