1st step to ZOHO - Technical Apti Questions - June 15th 2016

   
                                                                  


                                                               TECHNICAL APTITUDE:

1)Predict  the output:

 main()

{
unsigned int i=65000;

while(i++!=0);

printf("%d",i);

}


2) Predict  the output:


void main()

{

int i;

char a[]="\0";

if(printf("%s\n",a))

printf("Ok here \n");

else

printf("Forget it\n");

}



3)  Predict  the output:

main()

{

char *str1="abcd";

char str2[]="abcd";

printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));

}

4) Predict  the output

void main()
{
char a[]="12345\0";

int i=strlen(a);

printf("here in 3 %d\n",++i);

}


5) What will be output if you will compile and execute the following c code?
void main(){
char c=125;
    c=c+10;
    printf("%d",c);
}

6)What will be output if you will compile and execute the following c code?

void main(){
 int a=2;
 if(a==2){
   a=~a+2<<1;
   printf("%d",a);
 }
 else{
  break;
 }
}


7) What will be output if you will compile and execute the following c code?

void main(){
  int x;
  for(x=1;x<=5;x++);
    printf("%d",x);
}


8) Predict  the output

char p[20];
char *s = "string";
int length = strlen(s);
int i;
for (i = 0; i < length; i++)
    p[i] = s[length — i];
printf("%s", p);


9) Predict  the output

#include <stdio.h>
int main()
{
    void demo();
    void (*fun)();
    fun = demo;
    (*fun)();
    return 0;
}

void demo()
{
    printf("hello");
}



10) ) Predict  the output

int incr(int i)
{
   static int count = 0;
   count = count + i;
   return (count);
}
main()
{
   int i,j;
   for (i = 0; i <=4; i++)
      j = incr(i);
}

11) Consider the following C declaration

struct {
    short s [5]
    union {
         float y;
         long z;
    }u;
} t;

Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment
considerations, is -------------

12) ) Predict  the output

#include<stdio.h>
int *check(static int, static int);

int main()
{
    int *c;
    c = check(10, 20);
    printf("%d\n", c);
    return 0;
}
int *check(static int i, static int j)
{
    int *p, *q;
    p = &i;
    q = &j;
    if(i >= 45)
        return (p);
    else
        return (q);
}

13) What will be output if you will compile and execute the following c code?

#include "stdio.h"
#include "string.h"
void main(){
   char *str=NULL;
   strcpy(str,"cquestionbank");
   printf("%s",str);
}

14) Predict  the output

#include <stdio.h>
void f(char**);
int main()
{
    char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
    f(argv);
    return 0;
}
void f(char **p)
{
    char *t;
    t = (p += sizeof(int))[-1];
    printf("%s\n", t);
}


15) Predict  the output

#include <stdio.h>

int main(void)
{
    int i;
    int *ptr = (int *) malloc(5 * sizeof(int));

    for (i=0; i<5; i++)
        *(ptr + i) = i;

    printf("%d ", *ptr++);
    printf("%d ", (*ptr)++);
    printf("%d ", *ptr);
    printf("%d ", *++ptr);
    printf("%d ", ++*ptr);

}


Thanks for Visiting, Hope this helps you.... Feel free to comment, Comments are welcome....

Comments

Popular Posts