GIYSCON  Placement Paper   Aptitude - General   Nandhanam Engg College, Tiruppatur, Tamil Nadu-23 Mar 2010

GIYSCON  Placement Paper   Aptitude - General   Nandhanam Engg College, Tiruppatur, Tamil Nadu-23 Mar 2010


  • Posted by  FreshersWorld 
    7 Jan, 2012

    1. What is the expected output of the code?

     
    #include
    #define concatinate(a,b) a##b
    #define same1(a) #a
    #define same2(a) same1(a)
    int main()
    {
    printf("%s\n",same2(concatinate(1,2)));
    printf("%s\n",same1(concatinate(1,2)));
    return 0;

    }

     

    2.The intention of the following program was to print 42 astericks('*') But it fails to do so. You have to add/replace/delete exactly one character in the program to make it work?

     
    Find as many solutions as possible
     
    #include
    int main()
    {
    int n = 42;
    for(int i = 0; i < n; i-- )
    printf("*");
    return 0;
    }

    3. What does this code do?
     
    #include
    void insert(char s[],int c)
    {
    int i,j;
    for(i=j=0;s[i]!='\0';i++)
    if(s[i]!=c)
    s[j++]= s[i];
    s[j]='\0';
    }

    int main()
    {
    char s[]="helloworld";
    insert(s,'l');
    printf("%s",s);
    return(0);
    }


    4. What is the output of the following code?
     
    #include
    #include
    int s(char *A[20],char *B[20])
    {
    char *a,*b;
    a=A;b=B;
    while(*a++!=*b++); *a=*b='\0';
    return strlen(A);
    }
    int main()
    {
    char A[20]="somestring",
    B[20]="debugthecbug";
    printf("%d %s %s\n",s(&A,&B),A,B);
    return 0;
    }

    5. Can you predict the output ?
     
    #include
    #define print(var) printf("%s : %d\n",#var,(var))
    int main()
    {
    int y = 100;
    int *p;
    p = new int;
    *p = 10;
    y = y/*p; /*dividing y by *p */;
    print(y);
    return 0;
    }

     

    6. Take the input as 4, and write the output of the following code.

     
    #include
    main()
    {
    int i=0;
    printf("%d %d\n",scanf(" %d",&i),i);
    printf("%d %d\n",i=4,i);
    }

     

    7. Predict the output of the following program.

     
    #include
    int main()
    {

    int a=3, b = 5;
    printf(&a["Ya!Hello! how is this? %s\n"], &b["junk/super"]);
    printf(&a["WHAT%c%c%c\n%c%c\n%c !\n"], 1["this"],
    2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);

    return 0;
    }


    8. What is the output of the following code?

     
    #include
    #include
    int main()
    {
    int *ptr=(int*)malloc(sizeof(int));
    *ptr=4;
    printf("%d",(*ptr)+++*ptr++);
    return(0);
    }

    9. What is the output of the following piece of code?
     
    #include
    int main(int k)
    {
    if(k<10)
    printf("%d ",main(k+1));
    return k;
    }


    10. Predict the output or error if any in the following code.

     
    #include
    main()
    {
    int i = 4;
    printf("%d %d %d",++i,i++,i*i);
    printf("\n");
    printf("%d %d %d",i*i,++i,i++);
    system("PAUSE");
    }

     

     

2009-2016 downloadmela.com. All rights reserved.