TCS_SET1

download TCS_SET1

of 18

Transcript of TCS_SET1

  • 8/9/2019 TCS_SET1

    1/18

    TCS

    1. {

    double d;

    int i,j=2,k,l;

    float f;

    k=l=d=100/3;

    i=(j=3/2)*2;

    l=(d=3/2)*2;

    }

    the value of i will be

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

    2.the value of d will be

    a)33b)33.33c)33.0d)none

    3.the value of l will be

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

    Use the following alternatives for questions 4 to 9

    a)intb)string c)chard)none

    4.'hi there'

    5.'a'6."11040"

    7.0xA

    8.0a

    9.'040'

    10.what would the following program do?

    main()

    {

    unsigned int i=0;

  • 8/9/2019 TCS_SET1

    2/18

  • 8/9/2019 TCS_SET1

    3/18

    15. if(i>>j) printf("true");else printf("false");

    16. if(i= =j) printf("true");else printf("false");

    17. if(i+j) printf("true");else printf("false");

    18.What is the value of d after executing the foll

    statements

    int d;

    char c='\0';

    d=(c= ='0'|| c= = '9');

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

    19. What is the value of i after executing the

    following statementsint i=2,j=10,k=5;

    i=++j%k++;j*=--k;

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

    20.In problem 19 what would be the value of j at the

    end

    a)50b)60c)55d)66

    Find the value of the foll expression

    21. 5+6%4a)2b)3c)7d)75

    22. 1

  • 8/9/2019 TCS_SET1

    4/18

    26. What is the value of x after executing the foll

    statements?

    int x,y=2,a=1,z;

    if(x=y%2) z=2; a=z;

    a)2b)0c)1d)none

    27.In the problem 26 what would be the value of z at

    the end

    a)2b)0c)1d)none

    28. In the prob;em 26 what would be the value of a at

    the end

    a)1b)0c)2d)none

    29.The o/p of the foll two line of code willbe

    int i=0;

    while(++i

  • 8/9/2019 TCS_SET1

    5/18

    others?

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

    32. if the i/p is "123a" what is the value of twos?

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

    Use the foll code for ans 33 to 35

    if(n>0)

    if(n>1)

    printf("positive");

    else

    printf("negative");

    33. if n is equal to 20 what is printed?

    a)positiveb)negativec)no printing is done34. if n is equal to -10 what is printed?

    a)positiveb)negativec)no printing is done

    35. if n is equal to 1 what is printed?

    a)positiveb)negativec)no printing is done

    36.What is the value of b after executing the foll

    statements?

    int a=0,b=2;

    if(a=0) b=0;

    else b*=10;

    a)2b)20c)10d)0

    37. What is the o/p of the foll statements?

    int i=0;

    doprintf("%d",i);

    while(i++

  • 8/9/2019 TCS_SET1

    6/18

    a)only call by refb)only call by value

    c)bothd)call by value and to a extent by ref

    40. if the num is equal to 99 what is the o/p of the

    foll lines of code

    while(num--!=0)

    {if((num%2)==0)

    continue;

    else

    printf("even number");

    break;

    }

    a)even number would be printed 2 times.

    b) even number would be printed 49 times.

    c) even number would be printed 50 times.

    d) even number would be printed once.

    41.A source file contains the foll lines of code

    extern int s;

    int t;

    static int u;

    main()

    { -------

    }

    which of the variables are available for the

    functions defined in a diff source file

    a)only sb)s and tc)only ud)s and u

    42. If a function is added at the end of the source

    {--}given in the 41st question ,what are the variables

    that can be accessed by the function

    a)all s,t and ub)only t and sc)only td)none

    43. When the foll fn is called for the third tme in a

    particular fn what will be the o/p?

    { static int s=0;

    int l=o;

  • 8/9/2019 TCS_SET1

    7/18

    s=s+1;

    l=l+1;

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

    a)1 1b)1 3c)3 1d)3 3

    44.In the foll source file the variable a can be

    accessed by

    main()

    {----}

    int a;

    F1()

    {----}

    F2(){-------}

    a)main,F1 and F2b)F1 onlyc)F1 and F2d)none

    45.what is the o/p of the foll program

    main()

    {int i=2;

    {int i=3;

    printf("%d",i);

    }

    }

    a)3b)2c)either 3 or 2d)erroneous case

    46. What will be the o/p of the foll programmain()

    { char *name="Name";

    change(name);

    printf("%s",name);

    }

    change(char *name)

    {

    char *nm="New name");

    name=nm;

    }

  • 8/9/2019 TCS_SET1

    8/18

    a)Nameb)New namec)Name=nm statement is not proper

    d)function call is not valid

    47. What is the o/p of the foll program

    main()

    {

    int i=2,j=3;

    swap(i,j);

    printf("%d %d",i,j);

    }

    swap(i,j);

    int i,j;

    ( int temp;temp=i,i=j,j=temp;}a)32b)22c)33d)23

    48. which of the foll declarations are valid

    i)float a,function(int *b);

    ii)float a,function();

    iii)float a,function(int *);

    a)i onlyb)i and ii onlyc)ii and iii only d)all

    are valid

    49.What is the o/p of the foll programs

    main()

    {

    int i=2;

    twice(2);

    printf("%d",i);}

    int twice(int)

    {

    /*not present in the xerox*/

    }

    a)4b)2c)some address

    50. Execution always starts from the first function

    declaration in the source file.the above statement is

    a)true b)falsec)can't say

  • 8/9/2019 TCS_SET1

    9/18

    51. Study the foll fns.

    printd(int n)

    { if(nb)?b:a;

    #define square(a) a*a

    main()

    { int i=2,j=3,k=1;

    printf("%d",max(i,j));

    printf("%d",square(k+1));

    }

    a)34b)24c)33d)23

    54. Preprocessor instruction must start with a #

    symbolin the first column in ANSI C.the above

    statement is

    a)trueb)falsec)can't say

    55. What is the o/p of the foll program?

    #define value

    main()

  • 8/9/2019 TCS_SET1

    10/18

    { printf("value %d",value);

    }

    a)valueb)4c)4=4 d)none

    56. Include files can be used for symbol

    definitions,macro defn and global values only

    a)the above is trueb)falsec)can't say

    Use the foll declaration for 57 to 59

    int A[10]=(0,2,4,8,16,32,64,128,256,512);

    57. * A+1-*A+3=?a)4b)-4c)-2d)-6

    58. A[6]-A[5]=?

    a)8b)16c)32d)64

    59. &A[5]-&A[1]=?

    a)2b)4c)2d)16

    60.Consider the declaration

    int a,b[10],*p,k=2;

    which of the foll is not valid?

    a)a=kb)b[0]=2c)p=&kd)b=p

    61. Consider the same declaration in problem 60

    which of the foll is not valida)*b=(int)&kb)b[1]=2c)p=bd)none

    Consider the foll statements for problems 62 to 66

    int a,b[5]={1,2,3,4,5},c,*p,k=5;

    p=b;

    ++*p;

    p+=2;

    After the above statements

    62. The value of *p is

  • 8/9/2019 TCS_SET1

    11/18

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

    63. Value of b[1] &b[2] are

    a)2,3b)2,2c)1,2d)can't say

    64. The value of p-bis

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

    65. Value of(*p-*b) is

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

    66.Value of(&p-&b[1]) is

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

    Consider the foll program for 67 &68

    main()

    {

    char a='a',b[]="b",*c="c",d='d';

    mixup(a,b,&c);

    }

    mixup(p1,p2,p3)

    char p1,*p2,**p3;

    {

    char *temp;

    temp=&p1;p1=*p3;*p3=temp;

    }

    after calling the fn mixup

    67.What is the value of *b

    a)ab)bc)cd)none

    68.What is the value of a

    a)ab)bc)cd)none

    69.Which of the foll is valid

    a)#typedef struct{int i;} in;

    b)typedef struct in(int i;};

  • 8/9/2019 TCS_SET1

    12/18

    c)#typedef struct(int i;);

    d)typedef struct{int i;}in;

    Consider the foll statements are executed and answer

    the foll

    int p=20,*q;

    q=&p;

    70.What are the values of *p and *q+1;

    a)20,21b)20,a random valuec)20,20d)none

    71.What is(q-(&p-2))

    a)2b)random valuec)not a valid expressiond)none72.For a ten element array the index ranges from

    a)1 to 10b)0 to 9c)any ten int in seriesd)any one

    of the above

    73. Consider the foll statements

    i)pointers can be added

    ii)pointers can be subtracted

    iii)integers can be added to pointers

    a)all correctb)iii is correct c)i and ii are

    correctd)ii and iii are correct

    74.consider the foll statements

    i)automatic arrays can be initiated in

    declarations

    ii)static arrays can be initialised indeclarations

    a)ii correctb)i correctc)both correctd)none

    75.Consider the foll statements

    i)a[0] is same as *a

    ii)a[1] is same as *a+i

    iii)a[2] is same as ++*a

    a)all are correctb)i is correctc)ii are

    correctd)iii are correct

  • 8/9/2019 TCS_SET1

    13/18

    76. What is the o/p for the foll fns.

    char name[]="T.C.S",*p;

    int i;

    p=name;

    while *p!=NULL

    { if(*p!='.')

    printf("%c",*p);

    ++p;

    }

    a)T.C.Sb)tcsc) d)none

    77. In the above probelm at the end what is (p-name)

    a)4b)6c)5d)7

    Consider the foll program for problems 78 & 79 with

    source

    file name prog

    main(x,y)

    int x;

    char *y[];

    {

    printf("%d %s",x,y[1]);

    }

    78.What would be the o/p if it is invoked prog

    a)0 progb)11c)1 progd)21

    79. what would be the o/p if it is invoked as arg1

    a)1,progb)1,arg 1c)2,progd)2,arg 1

    80. Consider the foll fns

    struct ADDRESS{

    char *name;

    char *city;

    int pin;

    };

  • 8/9/2019 TCS_SET1

    14/18

    struct ADDRESS adr = {"name","delhi",123};

    struct ADDRESS *adradr;

    which of the foll references are valid?

    i)adr name

    ii)adradrpin

    iii)adr.name

    iv)adradr.pin

    a)ii and iiib)i and iiic)i onlyd)ii only

    After the foll functions

    struct point{

    int x;int y;

    polygon[]={1,2,1,4,2,4,2,2};

    struct point *a;

    a=polygon;

    ((a++)x)++;

    81. a-polygon=?

    a)1b)2c)2 * word size in bytesd)2 * int size in

    bytes

    82. Which of the foll expression is equal to 2

    a)polygon.xb)a xc)polygonx d)ay

    83. Is the foll valid?

    size of a structure is always equal to sum ofthe sizes of its member

    a)validb)invalidc)can't say

    84. What is the o/p of the foll fns?

    int I=20;

    a)20b)024c)020d))none

    85. What is the o/p of the foll sts.

    int I=20;

    printf("%x",i);

  • 8/9/2019 TCS_SET1

    15/18

    a)X14b)0110c)20d)none of the above

    86. Consider the foll sts

    float x,y;

    scanf("%f %f",&x,&y);

    If the i/p stream is 24.0 3 4

    what are the values of x and y?

    a)24.0 and 3.0b)24.0 and a random value

    c)24.0 and 4.2d)erroneous syntax for

    scanf

    87. The fns called by the main() program shouldnecessarily be ened in the same source file in the same

    order

    a)trueb)falsed)should be in the same source file

    but the order can be diff

    88. The value of p after the foll is

    char *p=" ";

    a)p is NULLb)*p is '\0'c)any of the above

    d)none of the above

    89.In the file open structure,

    A=fopen(B,C);

    B is

    a)pointer to the char array which has the file name

    b)name of the file enclosed between two double quotes.c) anyone of the above

    d)mode at access to the files

    90.In the foll st.

    X=malloc(Y)

    which of the foll stmts is correct?

    a) X will be the size of the array pointed to by Y

    b)Y points to the location where the memory allocation

    is to be made

    c)X will point to the memory allocated by malloc

  • 8/9/2019 TCS_SET1

    16/18

    d)none of the above

    91. what is FILE

    a)structure defined in stdio.h

    b)file pointer defined in stdio.h for standard i/p

    c) file pointer defined in stdio.h for default o/p

    d)none of the above

    92. The foll fn

    A=calloc(B); /*A is of type char * and B is

    a)validb)invalidc)valid if A is pointer to

    integerd)none

    93.What would be the o/p of the foll stmts

    union{int no;

    char ch;

    }unone;

    unone.ch=2;

    unone.no=0;

    printf("???%d",unone.ch);

    a)2b)a null charc)0d)none of the above

    94.which of the foll declarations is not valid

    a)union {

    int i;

    char j;

    }u;b)union{

    int i;

    char i;

    };

    c)union { int i;

    FILE k;

    }u;

    d)union utag{

    int i;

    float j;

  • 8/9/2019 TCS_SET1

    17/18

    }u[10];

    95.With the foll declarations

    char *s,*t,u[10],v[20];

    which of the foll fn call is syntactically valid

    a)strcpy(s,t) b)strcpy(t,u)c)strcpy(u,v)d)all of

    the above

    96.Which of the foll lines has error

    main()/*1*/

    { /*2*/

    int i,j;/*3*/

    ++i; /*4*/++j;/*5*/

    i=i+j;/*6*/

    j++/*7*/

    printf("%d %d",i,j);/*8*/

    a)2b)6c)8d)none of the above

    97. What is the diff between printf and fprintf

    a)printf is for std o/p & fprintf is for o/p into any

    defined file

    b)fprintf is not a valid fn

    c)fprintf is a macro which is defined using fprintf

    fn

    d) None of the above

    98. If p& q are pointers pointing to data of a similar

    type which of the foll are validi)*(p+q)ii)*(p-q)iii)*p-*q

    a)iii onlyb)ii and iii onlyc)ii onlyd)iii is

    invalid sometimes

    99. Which of the foll statements are true

    i)arrays of structures are permitted in C

    ii)arrays of pointer to fns are permitted in c

    iii)arrays of basic datatypes are permitted in c

    a)i,ii,iiib)i,iiic)iii onlyd)none

  • 8/9/2019 TCS_SET1

    18/18

    100.Consider the foll declarations

    char c;

    int i;

    float f;

    which of the foll is permitted syntactically

    a)(int *)&cb)(char *)&i c)(char *)&fd)all of

    the above