Friday, July 22, 2011

C Aptitude - P2


1.      main()
{
            extern int i;
            i=20;
printf("%d",i);
}

2.   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);
}

3.     main()
{
            char *p;
            printf("%d %d ",sizeof(*p),sizeof(p));
}
4.   main()
{
            int i=3;
            switch(i)
             {
                default:printf("zero");
                case 1: printf("one");
                           break;
               case 2:printf("two");
                          break;
              case 3: printf("three");
                          break;
              } 
}

5.  main()
{
              printf("%x",-1<<4);
}

Find the answers and check your answers on tomorrow(23-07-2011)

1 comment: