5th step to ZOHO - Technical Aptitude




TECHNICAL APTITUDE







1)#include
int main()
{
int y = 1;
if (y & (y = 2))
printf("true %d\n", y);
else
printf("false %d\n", y);

}




2)    #include 
    int main()
    {
        if (~0 == 1)
            printf("yes\n");
        else
            printf("no\n");
    }


3) What will be output of following c code?
void main()
{
struct bitfield
{
unsigned a:5;
unsigned c:5;
unsigned b:6;

}bit;
char *p;
struct bitfield *ptr,bit1={1,3,3};
p=&bit1;
p++;
clrscr();
printf("%d",*p);
getch();
}

 
4)    #include
void main()
{
       int a = 5, b = -7, c = 0, d;
       d = ++a && ++b || ++c;
       printf("\n%d%d%d%d", a, b, c, d);
}


5)





6)




7)




8)Consider the following three C functions :
[PI] int * g (void)
{
  int x = 10;
  return (&x);
}

[P2] int * g (void)
{
  int * px;
  *px = 10;
  return px;
}
  
[P3] int *g (void)
{
  int *px;
  px = (int *) malloc (sizeof(int));
  *px = 10;
  return px;
}
Which of the above three functions are likely to cause problems with pointers?

9)
Would the following code compile successfully?

main()
{

Printf(“%c”,7[‘Sundaram’]);

}
10)
#include
#include
 
int main()
{
    char str[] = "India\0\BIX\0";
    printf("%s\n", str);
    return 0;
}


11)
#include
int main()
{
   int n;
   for(n = 7; n!=0; n--)
     printf("n = %d", n--);
   getchar();
   return 0;
}


12)
# include
# define scanf  "%s Geeks For Geeks "
main()
{
   printf(scanf, scanf);      
   getchar();
   return 0;
}


13)
#include
#include
enum {false, true};
int main()
{
   int i = 1;
   do
   {
      printf("%d\n", i);
      i++;
      if (i < 15)
        continue;
   } while (false);

   getchar();
   return 0;
}


14)
int main()
{
   char str[]= "geeks\nforgeeks";
   char *ptr1, *ptr2;
      
   ptr1 = &str[3];
   ptr2 = str + 5;
   printf("%c", ++*str - --*ptr1 + *ptr2 + 2);
   printf("%s", str);
  
   getchar();
   return 0;
}


15)
#include
int fun(int n)
{
    int i, j, sum = 0;
    for(i = 1;i<=n;i++)
        for(j=i;j<=i;j++)
            sum=sum+j;
    return(sum);
}

int main()
{
    printf("%d", fun(15));
    getchar();
    return 0;
}


Comments

Popular Posts