447 Sonata

download 447 Sonata

of 10

Transcript of 447 Sonata

  • 8/9/2019 447 Sonata

    1/10

    Sample Technical Paper

    1. Point out error, if any, in the following program

    main()

    { int i=1;

    switch(i)

    {

    case 1:

    printf("\na!ioactie cats hae 1# half$lies");

    %rea&;

    case 1'*:

    printf("\n+ottle for rent $inuire within");

    %rea&;

    -

    -

    ns. /o error. 0onstant epression li&e 1'* are accepta%le in cases of a

    switch.

    . Point out the error, if any, in the following

    program

    main()

    {

    int a=12,%;

    a3= 4 5 %=122 : %=22;

    printf("\n6!",%);

    -

    ns. lalue reuire! in function main(). 7he secon! assignment shoul! %e

    written in parenthesis as follows:

    a3= 4 5 %=122 : (%=22);

    8. 9n the following co!e, in which or!er the functions woul! %e calle!5

    a= f1(8,1*)'f(1*)f8();

  • 8/9/2019 447 Sonata

    2/10

    a) f1, f, f8 %) f8, f, f1

    c) 7he or!er may ary from compiler to compiler !) /one of the a%oe

    *. hat woul! %e the output of the following program5

    main()

    {

    int i=*;

    switch(i)

    {

    !efault:

    printf("\n mouse is an elephant %uilt %y the

    s perfect");

    -

    -

    a) mouse is an elephant %uilt %y the

  • 8/9/2019 447 Sonata

    3/10

    -

    a) 4 %) 11 c) error !) gar%age alue

    B. 9n which line of the following, an error woul! %e

    reporte!5

    1. ?!efine 090CD() (8.1*'');

    . main()

    8. {

    *. float r=1.2,c;

    4. c= 090CD(r);

    B. printf("\n6f",c);

    E. if(090CD(r))==B.#)

    #. printf("\nFo%%le!ygoo&");

    G. -

    a) line 1 %) line 4 c) line B !) line E

    E. hat is the type of the aria%le % in the following !eclaration5

    ?!efine HI7P7 float'

    HI7P7 a,%;

    a) float %) float pointer c) int !) int pointer

    #. 9n the following co!e;

    ?inclu!eJst!io.h3

    main()

    {

    9HK 'fp;

    fp= fopen("trial","r");

    -

    fp points to:

    a) 7he first character in the file.

    %) structure which contains a "char" pointer which points to the first

    character in the file.

    c) 7he name of the file. !) /one of the a%oe.

  • 8/9/2019 447 Sonata

    4/10

    G. e shoul! not rea! after a write to a file without an interening call to

    fflush(), fsee&() or rewin!() J 7CKH@K3

    ns. 7rue

    12. 9f the program (myprog) is run from the comman! line as myprog 1 8 ,

    hat woul! %e the output5

    main(int argc, char 'argLM)

    {

    int i;

    for(i=2;iJargc;i)

    printf("6s",argLiM);

    -

    a) 1 8 %) 0:\DNPIF.KOK 1 8

    c) DNP !) /one of the a%oe

    11. 9f the following program (myprog) is run from the comman! line as

    myprog 1 8, hat woul! %e the output5

    main(int argc, char 'argLM)

    {

    int i,=2;

    for(i=2;iJargc;i)

    = atoi(argLiM);

    printf("6!",);

    -

    a) 1 8 %) B c) error !) "18"

    1. 9f the following program (myprog) is run from the comman! line as

    myprog mon!ay tues!ay we!nes!ay thurs!ay,

    hat woul! %e the output5

    main(int argc, char 'argLM)

    {

    while($$argc 32)

    printf("6s",'arg);

    -

  • 8/9/2019 447 Sonata

    5/10

    a) myprog mon!ay tues!ay we!nes!ay thurs!ay %) mon!ay tues!ay

    we!nes!ay thurs!ay

    c) myprog tues!ay thurs!ay !) /one of the

    a%oe

    18. 9n the following co!e, is p an integer or an integer pointer5

    type!ef int' ptr

    ptr p1,p;

    ns. 9nteger pointer

    1*. Point out the error in the following program

    main()

    {

    const int ;

    =1#;

    printf("6!",);

    -

    ns. shoul! hae %een initialiQe! where it is !eclare!.

    14. hat woul! %e the output of the following program5

    main()

    {

    int y=1#;

    const int =y;

    printf("6!",);

    -

    a) 1# %) Far%age alue c) Krror !) 2

    1B. hat is the !ifference %etween the following

    !eclarations5

    const char 's;

    char const 's;

    ns. /o !ifference

    1E. hat woul! %e the output of the following program5

    main()

  • 8/9/2019 447 Sonata

    6/10

    {

    char near ' near 'ptr1;

    char near ' far 'ptr;

    char near ' huge 'ptr8;

    printf("6! 6! 6!",siQeof(ptr1),siQeof(ptr),siQeof(ptr8));

    -

    a) 1 1 1 %) 1 * c) * * !) * * *

    1#. 9f the following program (myprog) is run from the comman! line as

    myprog fri!ay tues!ay sun!ay,

    hat woul! %e the output5

    main(int argc, char'argLM)

    {

    printf("6c",''arg);

    -

    a) m %) f c) myprog !) fri!ay

    1G. 9f the following program (myprog) is run from the comman! line as

    myprog fri!ay tues!ay sun!ay,

    hat woul! %e the

    output5

    main(int argc, char 'argLM)

    {

    printf("6c",'argL1M);

    -

    a) r %) f c) m !) y

    2. 9f the following program (myprog) is run from the comman! line as

    myprog fri!ay tues!ay sun!ay,

    hat woul! %e the output5

    main(int argc, char 'argLM)

    {

    while(siQeofarg)

    printf("6s",argL$$siQeofargM);

  • 8/9/2019 447 Sonata

    7/10

    -

    a) myprog fri!ay tues!ay sun!ay %) myprog fri!ay tues!ay

    c) sun!ay tues!ay fri!ay myprog !) sun!ay tues!ay fri!ay

    1. Point out the error in the following program

    main()

    {

    int a=12;

    oi! f();

    a=f();

    printf("\n6!",a);

    -

    oi! f()

    {

    printf("\nRi");

    -

    ns. 7he program is trying to collect the alue of a "oi!" function into an

    integer aria%le.

    . 9n the following program how woul! you print 42 using p5

    main()

    {

    int aLM={12, 2, 82, *2, 42-;

    char 'p;

    p= (char') a;

    -

    ns. printf("\n6!",'((int')p*));

    8. oul! the following program compile5

    main()

    {

    int a=12,';

    oi! '&;

    =&=Sa;

  • 8/9/2019 447 Sonata

    8/10

    ;

    &;

    printf("\n6u6u",,&);

    -

    a) Nes %) /o, the format is incorrect

    c) /o, the arithmetic operation is not permitte! on oi! pointers

    !) /o, the arithmetic operation is not permitte! on pointers

    *. ccor!ing to /@9 specifications which is the correct way of !eclaring

    main() when it receies comman! line arguments5

    a) main(int argc, char 'argLM) %) main(argc,arg) int argc; char 'argLM;

    c) main() {int argc; char 'argLM; - !) /one of the a%oe

    4. hat error woul! the following function gie on compilation5

    f(int a, int %)

    {

    int a;

    a=2;

    return a;

    -

    a) missing parenthesis in the return statement %) 7he function shoul! %e

    !eclare! as int f(int a, int %)

    c) re!eclaration of a !) /one of the a%oe

    B. Point out the error in the following program

    main()

    {

    const char 'fun();

    'fun()=>>;

    -

    const char 'fun()

    {

    return "Rello";

  • 8/9/2019 447 Sonata

    9/10

    -

    ns. fun() returns to a "const char" pointer which cannot %e mo!ifie!

    E. hat woul! %e the output of the following program5

    main()

    {

    const int =4;

    int 'ptr;

    ptr=S;

    'ptr=12;

    printf("6!",);

    -

    a) 4 %) 12 c) Krror !) Far%age alue

    #. switch statement cannot inclu!e

    a) constants as arguments %) constant epression as

    arguments

    c) string as an argument !) /one of the a%oe

    G. Row long the following program will run5

    main()

    {

    printf("\n@onata @oftware");

    main();

    -

    a) infinite loop %) until the stac& oerflows

    c) ll of the a%oe !) /one of the a%oe

    82. In com%ining the following statements, you will get char'p;

    p=malloc(122);

    a) char 'p= malloc(122) %) p= (char')malloc(122)

    c) ll of the a%oe !) /one of the a%oe

    81. hat is the output of the following program5

    main()

    {

  • 8/9/2019 447 Sonata

    10/10

    int n=4;

    printf("\nn=6'!",n,n);

    -

    a) n=4 %) n=4 c) n= 4 !) error