Knowledge check.

- Choose one best answer from given 4 choices for each questions.
- Review before submit as you wont get a chance to review after submit.
- Max Time for quiz is 30 mins and Exam is 90 mins.
- Login is not required for an exam or a quiz.
- By submitting you formally acknowledge and accept terms and conditions mentioned here.

Question Number 1

Give the output of the following code snippet :
void main()
{
    char str1[15]="Hello World";
    char str[10]="Yellow";
    char *str2="World";
    char *str3;
    str3=strcat(str,str2);
    printf("%s",str3);
}

Question Number 2

Give the output of the following code snippet :
union p
{
    unsigned int x : 1;
    unsigned int y : 1;
};
int main()
{
    union p p;
    p.x = 2;
    p.y = 4;
    printf("%d %d",p.x, p.y);
}

Question Number 3

Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */

extern int value = 100;
/* Test1.c */

int value = 200;
void func()
{
    int value = 200;
    printf ( "Output = %d", value );
}

/* Test2.c */

#include"Test1.h"
int value = 100;

void main ()
{
    printf ( "Output = %d", value );
}

Question Number 4

Give the output of the following code snippet :
int main()
{
    int i=3, *j, k;
    j = &i;
    printf("%d\n", i**j-*j);
    return 0;
}

Question Number 5

Give the output of the following code snippet :
struct node
{
    int x;
    struct node *next;
}*Head;

void SortList()
{
    node *temp1,*temp2,*temp3,*temp4,*temp5;
    temp4=NULL;
    while(temp4!=Head->next)
    {
        temp3=temp1=Head;
        temp2=temp1->next;
        while(temp1!=temp4)
        {
            if(temp1->x <  temp2->x)
            {
                if(temp1==Head)
                {
                    temp5=temp2->next;
                    temp2 -> next=temp1;
                    temp1->next=temp5;

                    Head = temp2;
                    temp3=temp2;
                }
                else
                {
                    temp5=temp2->next;
                    temp2 -> next=temp1;
                    temp1->next=temp5;

                    temp3->next = temp2;
                    temp3=temp2;
                }
            }
            else
            {
                temp3=temp1;
                temp1=temp1->next;
            }
            temp2=temp1->next;
            if(temp2 == temp4)
                temp4=temp1;
        }
    }
}
void AddNode( int num )
{
    struct node *temp;
    temp=(struct node *)malloc(sizeof(struct node));
    temp->x=num;
    temp->next=Head;
    Head=temp;

}
void  Display()
{
    struct node *r;
    r=Head;
    while(r!=NULL)
    {
        printf("%d ",r->x);
        r=r->next;
    }
    printf("\n");
}

int main()
{
    AddNode(10);
    AddNode(5);
    AddNode(6);
    AddNode(20);
    AddNode(3);
    AddNode(100);
    AddNode(50);
    SortList();
    Display();
}

Question Number 6

Give the output of the following code snippet :
int main()
{

    int arry[5]= {20,10,5,0};
    arry[5]=10;
    arry[6]=++(*arry);
    printf("%d %d",3[arry],*arry);
}

Question Number 7

Give the output of the following code snippet :
int main()
{
    void *p;
    int a[4] = {1, 2, 3, 3};
    p = &a[3];
    int *ptr = &a[0];
    int n = (int *)p - ptr;
    printf("%d\n", n);
}

Question Number 8

Give the output of the following code snippet :
void main()
{
    int a=20,c=10,b=0;
    _asm
    {
        mov eax,30
        mov ebx,a
        cmp eax,dword ptr[c]
        je Label2
        mov b,eax
        Label2:
        mov ecx,c
        cmp eax,ecx
        jns Label1
        mov c,eax

    }
Label1:	printf("%d %d",b,c);
}

Question Number 9

Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
extern int value;
void func(int);
/* Test1.c */
#include "Test1.h"

void func(int arg)
{
    value=200;
    printf ( "Output = %d\n", arg+value );

}


/* Test2.c */
#include "Test1.h"

static int arg=10;
void main ()
{
    value = 300;
    func(arg+value);
}

Question Number 10

Give the output of the following code snippet :
void main()
{
    int k, sum = 0, prod = 0, l = 3;
    _asm
    {
        mov         dword ptr[k], 0FFFFFFFDh
        jmp         Label1
        Label4 : mov         eax, dword ptr[k]
        add         eax, 1
        mov         dword ptr[k], eax
        Label1 : cmp         dword ptr[k], 3
        jge         Label2

        mov         ecx, dword ptr[k]
        imul        ecx, dword ptr[l]
        mov         dword ptr[prod], ecx

        cmp         dword ptr[k], 0

        jne         Label3

        mov         edx, dword ptr[prod]
        add         edx, dword ptr[l]
        mov         dword ptr[sum], edx

        Label3 : jmp         Label2

        jmp         Label4

    }
Label2:	printf("%d %d", sum, prod);
}

Question Number 11

Give the output of the following code snippet :
void main()
{
    int x=10,y=20,arr[3],i;
    for(i=0; i< 3; i++)
    {
        arr[i]=y++;
        printf("%d  ",arr[i]+x++);
    }
}

Question Number 12

Give the output of the following code snippet :
union Test
{
    char str[20];
};

int main()
{
    union Test st1, st2;
    strcpy(st1.str, "Hello");
    st2 = st1;
    st1.str[0] = 'J';
    st2.str[0] = 'Y';
    printf("%s",st1.str);
}

Question Number 13

Give the output of the following code snippet :
void main()
{
    int a = 10;
    _asm
    {
        mov         eax, dword ptr[a]
        add         eax, 5
        mov         dword ptr[ebp - 0D0h], eax
        cmp         dword ptr[ebp - 0D0h], 5
        je          Label1
        cmp         dword ptr[ebp - 0D0h], 0Ah
        je          Lable2
        cmp         dword ptr[ebp - 0D0h], 0Fh
        je          Lable3
        jmp         Lable4

        Label1 : mov         eax, dword ptr[a]
        add         eax, 0Ah
        mov         dword ptr[a], eax

        Lable2 : mov         eax, dword ptr[a]

        add         eax, 32h
        mov         dword ptr[a], eax

        Lable3 : mov         eax, dword ptr[a]
        add         eax, 64h
        mov         dword ptr[a], eax

    }
Lable4:	printf("%d", a);
}

Question Number 14

Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */

extern int value = 300;
/* Test1.c */

void func()
{
    int value = 200;
    printf ( "Output = %d", value );
}

/* Test2.c */

#include"Test1.h"

void main ()
{
    printf ( "Output = %d", value );
}

Question Number 15

Give the output of the following code snippet :
int main()
{
    char *str = "Hello";
    char strc[] = "World";
    strcpy(strc, str);
    printf("%s\n", strc);
    return 0;
}

Question Number 16

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])

{
    int a = 0, b =0, c=0,d=0;
    __asm
    {
        push 10
        push 20
        push 30
        mov ebx,50
        mov eax, 40
        call label1
        add eax,ebx
        mov a,eax
        mov ecx,25
        add ecx,eax
        mov c,ecx
        add esp, 12
        jmp Label2
        label1:
        mov eax, dword ptr[esp + 4]
        mov a, eax
        add a, ebx
        mov eax, dword ptr[esp + 4]
        mov b, eax
        or b,ebx
        mov eax, dword ptr[esp + 8]
        or edx,ecx
        mov c,eax
        and edx,ecx
        mov d,ebx
        ret
    }
Label2:
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 17

Give the output of the following code snippet :
char *func()
{
    char *s;
    s=(char*)calloc(20*sizeof(char));
    strcpy(s,"Hello World");
    return s;
}
void main()
{
    char *s;
    s=func();
    printf("%s",s);
}

Question Number 18

Give the output of the following code snippet :
int main()
{
    int x=10,y=1;
    int z=++x || y--;
    if(z <  x^y || y%x)
        printf("%d",z++- ++x);
    else
        printf("%d",z--+ --y);
}

Question Number 19

Give the output of the following code snippet :
struct student
{
    char *name;
};
struct student fun(void)
{
    m.name = "Jenn";
    return m;
}
void main()
{
    struct student m = fun();
    printf("%s ", m.name);
}

Question Number 20

Give the output of the following code snippet :
int main()
{
    char str[] = "Hello";
    char *s = str;
    printf("%s\n", s++ +3);
    return 0;
}

Question Number 21

Give the output of the following code snippet :
struct
{
    char *name;
    union
    {
        char *sval;
    } u;
} symtab[10];
void main()
{
    symtab.u.sval="HelloWorld";
    printf("%s",symtab.u.sval);
}

Question Number 22

Give the output of the following code snippet :
int main()
{
    int i, *p, q;
    _asm
    {
        mov         dword ptr[i], 2
        lea         eax, [i]
        mov         dword ptr[p], eax
        mov         ecx, dword ptr[p]
        mov         edx, dword ptr[ecx]
        add         edx, 0Ah
        mov         eax, dword ptr[p]
        mov         dword ptr[eax], edx
        mov         ecx, dword ptr[p]
        mov         edx, dword ptr[ecx]
        mov         dword ptr[q], edx
        mov         eax, dword ptr[p]
        add         eax, 4
        mov         dword ptr[p], eax
    }
    printf("%d", q);
}

Question Number 23

Give the output of the following code snippet :
struct temp
{
    int a;
    int b;
    int c;
} p[] = {10,20};
void main()
{
    printf("%d", sizeof(p));
}

Question Number 24

Which of the following statements is true about an array of void data type?
< NIL>

Question Number 25

Give the output of the following code snippet :
void f(int (*a)[2])
{
    a[0][1] = 3;
    int i = 0, j = 0;
    for (i = 0; i <  2; i++)
        for (j = 0; j <  2; j++)
            printf("%d ", a[i][j]);
}
void main()
{
    int a[2][2] = {0};
    f(a);
}

Question Number 26

Give the output of the following code snippet :
void main()
{
    char a[10][6] = {"Hola","Hello","Jello"};
    printf("%s", a+1);
}

Question Number 27

Give the output of the following code snippet :
union Test
{
    char str[20];
};

int main()
{
    union Test st1, st2;
    strcpy(st1.str, "Hello");
    st2 = st1;
    st1.str[0] = 'J';
    printf("%s",st2.str);
}

Question Number 28

Give the output of the following code snippet :
struct p
{
    char *name;
    struct p *next;
};
struct p *ptrary;
int main()
{
    struct p p, q;
    p.name = "SourceLens";
    ptrary= &p;
    strcpy(q.name, p.name);
    ptrary = &q;
    printf("%s\n", ptrary->name);
    return 0;
}

Question Number 29

Give the output of the following code snippet :
char *func()
{
    char *str=(char *)malloc(20);
    strcpy(str,"Hello");
    return str;
    free(str);

}
void main()
{
    char *s;
    s=func();
    printf("%s",s);
}

Question Number 30

Give the output of the following code snippet :
void main()
{
    int a=10,b=20,c=30;
    unsigned int d=12;
    int x=10,y=20,z=30;
    x=a && b || c;
    y|=3;
    z=d & d;
    printf("%d %d %d",x,y,z);
}

Question Number 31

Give the output of the following code snippet :
int main()
{
    int i, *j, k;
    _asm
    {
        mov         dword ptr[i], 0Fh
        lea         eax, [i]
        mov         dword ptr[j], eax
        mov         ecx, dword ptr[j]
        mov         edx, dword ptr[ecx]
        add         edx, 0Ah
        mov         eax, dword ptr[j]
        mov         dword ptr[eax], edx
        mov         ecx, dword ptr[j]
        mov         edx, dword ptr[i]
        imul        edx, dword ptr[ecx]
        mov         eax, dword ptr[j]
        sub         edx, dword ptr[eax]
        mov         dword ptr[k], edx
    }
    printf("%d\n", k);
}

Question Number 32

Give the output of the following code snippet :
int main()
{
    int ary[2][3];
    int j = 20;
    *ary[0] = j;
    printf("%d\n", *ary[0]);
}

Question Number 33

Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
void func1(int);
extern int arg = 10;


/* Test2.h */
extern int value;
void func(int);

/* Test1.c */

#include"Test2.h"
void func1(int);
void func(int arg)
{
    func1(arg);
    value = 200;
    printf("Output = %d\n",arg+value);
}

/* Test2.c */
#include"Test2.h"

int value = 200;
void func1(int arg)
{
    value = 100;
    printf ( "Output = %d\n", arg+value );

}



/* Test3.c */

#include "Test1.h"
#include "Test2.h"

void main ()
{
    func(arg);
}

Question Number 34

Give the output of the following code snippet :
void main()
{
    int a[3] = {1, 2, 3};
    int *p = a;
    printf("%d  %d", *p, *a);
}

Question Number 35

Give the output of the following code snippet :
int func()
{
    int *ptr;
    int x=100;
    ptr=&x;
    return *ptr;
}
void main()
{
    int (*f[5])();
    f[0]=func;
    printf("%d",(*f[0])());
}

Question Number 36

Give the output of the following code snippet :
void f(int i)
{
    printf("%d\n", i);
}
void (*fptr)(int) = f;
void main()
{
    fptr(10);
}

Question Number 37

Give the output of the following code snippet :
void main()
{
    int a=20,c=10,b=30;
    _asm
    {
        mov eax,-20
        mov ebx,a
        add eax,ebx
        jz Label2
        mov b,eax
        Label2:
        mov ecx,dword ptr[b]
        sub eax,ecx
        jz Label1
        and eax,dword ptr[c]
        mov c,eax

    }
Label1:	printf("%d %d",b,c);
}

Question Number 38

Give the output of the following code snippet :
int main()
{

    int (*p)[5];
    int a[][5]= {1,2,3,4,5,6};
    p=a;
    int *q[]= {*a,*a+1,*a+2,*a+3,*a+4};
    printf("%d %d %d",**q,**p+2,**a);

}

Question Number 39

Give the output of the following code snippet :
void main()
{
    int (*arr)[3];
    int arry[5]= {1,2,3};
    arr=&arry;
    printf("%d",*(*arr));
}

Question Number 40

Give the output of the following code snippet :
struct student
{
    char *c;
};
void main()
{
    struct student m;
    struct student *s = &m;
    s->c = "SourceLens";
    printf("%s", m.c);
}

Question Number 41

Give the output of the following code snippet :
void m(int p, int q)
{
    printf("%d %d\n", p, q);
}
void main()
{
    int a = 6, b = 5;
    m(&a);
}

Question Number 42

Give the output of the following code snippet :
void main()
{
    char str1[12]="Hello world";
    char *str="Yellow World";
    char *x,*y;
    strcpy(str1,str);
    printf("%s",str1);
}

Question Number 43

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])

{
    int a = 0, b =0, c=0,d=0;
    __asm
    {
        push 10
        push 20
        push 30
        mov ebx,50
        mov eax, 40
        mov ecx,60
        call label1
        add eax,ebx
        mov a,eax
        add ecx,eax
        mov c,edx
        add esp, 12
        jmp Label2
        label1:
        mov eax, dword ptr[esp + 4]
        mov a, eax
        add a, ebx
        mov eax, dword ptr[esp + 12]
        mov b, eax
        or b,ebx
        mov eax, dword ptr[esp + 16]
        or edx,ecx
        mov c,eax
        and edx,ecx
        mov d,ebx
        ret
    }
Label2:
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 44

Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */

int value=100;
/* Test1.c */

void func()
{
    int value = 200;
    printf ( "Output = %d", value );
}

/* Test2.c */

#include< Test1.h>

int value = 100;
void main ()
{
    printf ( "Output = %d", value );
}

Question Number 45

Give the output of the following code snippet :
int main()
{
    int *p = (int *)2;
    int *q = (int *)0;
    printf("%d", p && q);
}

Question Number 46

Give the output of the following code snippet :
struct p
{
    int x;
    char c;

};
int main()
{
    struct p p1[2];
    struct p *ptr1 = p1;
    ptr1->c='H';
    printf("%d",ptr1->c);
}

Question Number 47

Give the output of the following code snippet :
int ConvertToHex(long int binVal)
{
    long int hexVal = 0, i = 1, rem=0;
    while (binVal != 0)
    {
        rem = binVal % 10;
        hexVal = hexVal + rem * i;
        i = i * 2;
        binVal = binVal / 10;
    }
    printf("%lX", hexVal);
    return 0;
}

void main()
{
    ConvertToHex(11001101);
}

Question Number 48

Give the output of the following code snippet :
int main()
{
    char str1[15] = "Hello World";
    char ch = 'W';
    char *str;
    str=strchr(str1,ch);
    printf("%s ", str);
    return 0;
}

Question Number 49

Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
extern int value;
void func();
/* Test1.c */
#include "Test1.h"
int value = 100;
void func()
{
    printf("Output = %d",value);
}

/* Test2.c */
#include "Test1.h"

int value = 200;
void func1()
{
    printf ( "Output = %d\n", ++value );

}


/* Test3.c */

#include "Test1.h"

void main ()
{
    func1();
    func();
}

Question Number 50

Give the output of the following code snippet :
int func()
{
    int **p;
    int *q;
    int x=100;
    p=&q;
    q=&x;
    return q;
}
void main()
{
    int (*f)();
    f=func;
    printf("%d",f());
}

Question Number 51

Give the output of the following code snippet :
void func(int arr[])
{
    *arr++;
    printf("%d ",(arr[0]));
}

int main()
{

    int n=10;
    int arry[n]= {1,2,3,4,5,6};
    func(arry);
}

Question Number 52

Give the output of the following code snippet :
union p
{
    int x;
    char y;
};
int main()
{
    union p p1,p2;
    p1.x = 10;
    p2.x = 12;
    printf("%d\n", p1.y);
}

Question Number 53

Give the output of the following code snippet :
void main()
{
    int a=20,b=30,c=40;
    unsigned int d=2;
    int x=1,y=2,z=30;
    x=a || b && 3 && d;
    y = a && 2 || b;
    d = d < <  1;
    printf("%d %d %d",x,y,d);
}

Question Number 54

Give the output of the following code snippet :
int main()
{
    int a[2][2] = {1, 2, 3, 4};
    int *ptr;
    ptr = &a[0][0];
    printf("%d\n", *ptr);

}

Question Number 55

Give the output of the following code snippet :
void print(int num,int num2,...)
{
    int i;
    va_list marker;
    va_start(marker,num);
    while((--num2) == 0)
    {
        i=va_arg(marker,int);
        printf("%d ",i);
    }
    va_end(marker);
}
int main(int argc, char *argv[])
{
    print(4,3,20,30);
}

Question Number 56

Give the output of the following code snippet run with the following commandline arguments: >Testfile.c Yellow Jello
/* Testfile.c */

int main(int argc, char *argv[])
{
    printf("%d", *++argv[1] );
    return 0;
}

Question Number 57

Give the output of the following code snippet :
int main()
{
    enum state  {working, failed};
    enum result {failed, passed};
    printf("%d",failed);
}

Question Number 58

Give the output of the following code snippet :
int main()
{
    int a = 20, b = 10,c=2;
    _asm
    {
        mov eax,100
        push eax
        push ebx
        mov ecx,esp
        sub ebx,ecx
        pop ebx
        pop eax
        mov a,eax
        mov b,ebx
    }
    printf("%d %d",a,b);
}

Question Number 59

Give the output of the following code snippet :
int func(int a,int b)
{
    int x=a++;
    int y=a--%b++;
    if (a>b)
        return(x);
    else
        return(y);
}

int main()
{
    int x=100,y=200;
    int z = func(100,200);
    printf("%d",z);
}

Question Number 60

Give the output of the following code snippet :
struct node
{
    int x;
    struct node *next;
}*Head;

void SortList()
{
    node *temp1,*temp2,*temp3,*temp4,*temp5;
    temp4=NULL;
    while(temp4!=Head->next)
    {
        temp3=temp1=Head;
        temp2=temp1->next;
        while(temp1!=temp4)
        {
            if(temp1->x <  temp2->x)
            {
                if(temp1==Head)
                {
                    temp5=temp2->next;
                    temp2 -> next=temp1;
                    temp1->next=temp5;

                    Head = temp2;
                    temp3=temp2;
                }
                else
                {
                    temp5=temp2->next;
                    temp2 -> next=temp1;
                    temp1->next=temp5;

                    temp3->next = temp2;
                    temp3=temp2;
                }
            }
            else
            {
                temp3=temp1;
                temp1=temp1->next;
            }
            temp2=temp1->next;
            if(temp2 == temp4)
                temp4=temp1;
        }
    }
}
void AddNode( int num )
{
    struct node *temp,*temp2;
    if(Head==NULL)
    {
        temp2=(struct node *)malloc(sizeof(struct node));
        temp2->x=num;
        temp2->next=NULL;
        Head=temp2;
    }
    else
        temp=Head;
    while(temp->next!=NULL)
        temp=temp->next;
    temp2=(struct node *)malloc(sizeof(struct node));
    temp2->x=num;
    temp2->next=NULL;
    temp->next=temp2;
}

void  Display()
{
    struct node *r;
    r=Head->next;
    while(r->next!=NULL)
    {
        printf("%d ",r->x);
        r=r->next;
    }
    printf("\n");
}

int main()
{
    AddNode(10);
    AddNode(5);
    AddNode(6);
    SortList();
    AddNode(20);
    AddNode(3);
    AddNode(100);
    AddNode(50);

    Display();
}

Question Number 61

Give the output of the following code snippet :
int main()

{
    int i = 3, a = 10, j = 1;
    _asm
    {
        Label1 :  mov         eax, dword ptr[a]
        add         eax, dword ptr[j]
        mov         dword ptr[a], eax
        mov         ecx, dword ptr[i]
        add         ecx, 1
        mov         dword ptr[i], ecx
        mov         edx, dword ptr[j]
        sub         edx, 1
        mov         dword ptr[j], edx
        jne         Label1 }
    printf("%d", a);
}

Question Number 62

Give the output of the following code snippet :
int sum(int first,...)
{
    int sum=0, count=0,i=first;
    va_list marker;
    va_start(marker,first);
    while(i!=-1)
    {
        sum+=i;
        count++;
        i=va_arg(marker,int);
    }
    va_end(marker);
    return sum;
}


int main(int argc, char *argv[])
{
    printf("%d",sum(2,3.5,4.5,-1));
}

Question Number 63

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])

{
    int a = 0, b = 0, c=0,d=0;
    __asm
    {
        push 10
        push 20
        push 30
        push 40
        mov ebx,30
        push ebx
        mov eax, 40
        mov ecx,label1
        call ecx
        add esp,0x10
        mov edx,Label2
        mov dword ptr[c],edx
        jmp dword ptr[c]
        label1:
        add esp,4
        mov eax, dword ptr[esp + 4]
        mov a, eax
        pop eax
        mov b, eax
        pop eax
        mov c,eax
        mov eax, dword ptr[esp + 8]
        mov d,eax
        sub esp,12
        ret

        Label2:mov c,ebx
        mov b,eax

    }
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 64

Give the output of the following code snippet :
void main()
{
    char s1[]="Hello";
    char *s2;
    int len=sizeof(s1);
    s2=(char*)malloc(len);
    memcpy(s2,s1,sizeof(s1));
    puts(s2);
}

Question Number 65

Give the output of the following code snippet :
void main()
{
    int a=30,c=-10,b=40;
    _asm
    {
        mov eax,40
        mov ebx,b
        sub eax,dword ptr[b]
        jo Label2
        mov edx,dword ptr[c]
        and edx,eax
        mov b,edx
        Label2:
        mov ecx,dword ptr[a]
        mov ebx,10
        cmp ecx,ebx
        je Label1
        add eax,ecx
        or eax,edx
        mov c,eax

    }
Label1:	printf("%d %d",b,c);
}

Question Number 66

Give the output of the following code snippet :
int main()
{
    int x=100,y=200;
    int z = x++ || y;
    int a= --z || ++y || x--;
    int b=a+(10,20,30,40);
    printf("%d %d",b,a);
}

Question Number 67

Give the output of the following code snippet :
int main()
{
    float x=0.3,y=10,z=20;
    if( x <  0.3)
        printf("%lf",y+z);
    else
        printf("%lf",z-y);
}

Question Number 68

Give the output of the following code snippet :
int DecToBin(int num)
{
    if (num == 0)
    {
        return 0;
    }
    else
    {
        return (num % 2) + 10 * DecToBin(num / 2);
    }
}

int main()
{
    printf("%d",DecToBin(200));
}

Question Number 69

Give the output of the following code snippet :
int main()
{
    const int x=200;
    int y;
    y=x;
    int z=++x+y;
    printf("%d",z);

}

Question Number 70

Give the output of the following code snippet :
int main()
{
    int a = 1;
    _asm
    {
        mov         eax, dword ptr[a]
        mov         dword ptr[ebp - 0D0h], eax
        cmp         dword ptr[ebp - 0D0h], 0
        je          Label1
        cmp         dword ptr[ebp - 0D0h], 2
        je          Label2
        cmp         dword ptr[ebp - 0D0h], 3
        je          Label3
        jmp         Label4

        Label1 : mov         dword ptr[a], 2

        Label2 : mov         dword ptr[a], 3

        jmp         Label4
        Label3 : mov         eax, dword ptr[a]
        add         eax, 4
        mov         dword ptr[a], eax

    }
Label4:	printf("%d", a);
}

Question Number 71

Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
extern int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
void func()
{
    value=200;
    printf ( "Output = %d\n", ++value );

}

/* Test2.c */
#include "Test1.h"

void func1()
{
    value=200;
    func();
    printf ( "Output = %d\n", ++value );

}


/* Test3.c */

#include "Test1.h"

int value = 400;
void main ()
{
    func1();
}

Question Number 72

Give the output of the following code snippet :
typedef struct stud
{
    int no;
    int no2;
    stud *link;
} stud;
void main()
{
    stud s;
    s.no=1001;
    printf("%d",s.no);
}

Question Number 73

Give the output of the following code snippet :
int main()
{
    int x=100,y=200;
    int z=++x || y--;
    if(z <  x%y || y%x)
        printf("%d",z++- ++x);
    else
        printf("%d",z--+ --y);
}

Question Number 74

Give the output of the following code snippet :
int mopn(int x, int y, int z)
{
    _asm
    {
        mov         eax,dword ptr [x]
        add         eax,dword ptr [y]
        sub			eax,dword ptr[z]
    }
}
void main()
{
    int(*fptr)(int a, int b, int c);
    int a = 0;
    fptr=mopn;
    _asm
    {
        push        12h
        push        1Dh
        push        10h
        call        dword ptr [fptr]
        add         esp,12
        mov         dword ptr [a],eax
    }
    printf("%d", a);
}

Question Number 75

Give the output of the following code snippet :
int main()
{
    int a = 1;
    _asm
    {
        mov         eax, dword ptr[a]
        mov         dword ptr[ebp - 0D0h], eax
        cmp         dword ptr[ebp - 0D0h], 1
        je          Label1
        cmp         dword ptr[ebp - 0D0h], 2
        je          Label2
        cmp         dword ptr[ebp - 0D0h], 3
        je          Label3
        jmp         Label4

        Label1 : mov         dword ptr[a], 2

        Label2 : mov         dword ptr[a], 3

        jmp         Label4
        Label3 : mov         eax, dword ptr[a]
        add         eax, 4
        mov         dword ptr[a], eax

    }

Label4 :	printf("%d", a);
}

Question Number 76

Give the output of the following code snippet :
int main()
{
    int a[5][5] = {{1, 2, 3}, {5, 2, 3, 4}};
    printf("%d",*a[3]);
}

Question Number 77

Give the output of the following code snippet :
void main()
{
    int a=20,c=10,b=30;
    _asm
    {
        mov eax,30
        mov ebx,a
        xor eax,dword ptr[c]
        jz Label2
        mov b,eax
        Label2:
        mov ecx,dword ptr[a]
        cmp eax,ecx
        js Label1
        and eax,dword ptr[b]
        mov c,eax

    }
Label1:	printf("%d %d",b,c);
}

Question Number 78

Give the output of the following code snippet :
int main()
{
    int *Pa1=0;
    int *Pa2=0;
    int *Pa3;

    int a=10,b=20;
    Pa1=&a;
    Pa2=&b;
    *Pa3=*Pa1**Pa2;

    printf("%d",*Pa3);
}

Question Number 79

Give the output of the following code snippet :
int func(int x)
{
    int *ptr;
    x=200;
    ptr=&x;
    return *ptr;
}
void main()
{
    int (*f)(int);
    f=func;
    printf("%d",(f)(100));
}

Question Number 80

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])

{
    int a = 0, b =0, c=0,d=0;
    __asm
    {
        push 10
        push 20
        mov ebx,30
        mov eax, 40
        mov ecx,60
        push 50
        push 70
        push 80
        call label1
        add eax,ebx
        mov a,eax
        mov b,ebx
        add esp, 20
        jmp Label2
        label1:
        mov eax, dword ptr[esp + 8]
        mov a, eax
        add a, ebx
        mov eax, dword ptr[esp + 12]
        mov b, eax
        mov eax, dword ptr[esp + 20]
        or edx,ecx
        mov c,eax
        sub edx,ecx
        sub edx,10
        mov d,edx
        ret
    }
Label2:
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 81

Give the output of the following code snippet :
void print(int num,va_list marker);
void disp(int num,...)
{
    va_list val;
    va_start(val,num);
    print(num,val);
}
void print(int num,va_list marker)
{
    int i,k,j;
    j=va_arg(marker,int);
    printf("%d ",j);
    va_end(marker);
}
int main(int argc, char *argv[])
{
    disp(100,10,20,30);
}

Question Number 82

Give the output of the following code snippet :
int print(int num,...)
{
    int sum=0, count=0,i,j,k;
    va_list marker;
    va_start(marker,num);
    j=va_arg(marker,int);
    printf("%d ",j);
    k=va_arg(marker,char);
    printf("%c ",k);
    va_end(marker);
    return sum;
}
int main(int argc, char *argv[])
{
    print(2,'X','Y');
}

Question Number 83

Give the output of the following code snippet :
void main()
{
    unsigned int a=10;
    unsigned int b=17;

    int c = a ^ 2;
    int d = ~b;

    printf("%d %d",c,d);

}

Question Number 84

Give the output of the following code snippet :
int main()
{
    char *ptr;
    *ptr = (char)malloc(30);
    strcpy(ptr, "Hello");
    printf("%s", ptr);
}

Question Number 85

Give the output of the following code snippet :
void main()
{
    int a[10] = {1};
    printf("%d %d", sizeof(a[10]),*a);
};

Question Number 86

Give the output of the following code snippet :
struct node
{
    int data;
    struct node *next;
    struct node *prev;
}*head;

void func( int num )
{
    struct node *temp,*temp2;
    if (head== NULL)
    {
        temp=(struct node *)malloc(sizeof(struct node));
        temp->data=num;
        temp->next=NULL;
        temp->prev=NULL;
        head=temp;
    }
    else
    {
        temp=head;
        while (temp->next!=NULL)
            temp=temp->next;
        temp2=(struct node *)malloc(sizeof(struct node));
        temp2->data=num;
        temp2->next=NULL;
        temp->next=temp2;
        temp2->prev=temp;
    }

}


void  display()
{
    struct node *r;
    r=head;
    while(r->next!=NULL)
        r=r->next;
    while(r!=NULL)
    {
        printf("%d ",r->data);
        r=r->prev->prev;
    }
}

void main()
{
    func(100);
    func(200);
    func(300);
    func(400);
    display();
}

Question Number 87

Give the output of the following code snippet :
void f(int a[][])
{
    a[0][1] = 3;
    int i = 0, j = 0;
    for (i = 0; i <  2; i++)
        for (j = 0; j <  2; j++)
            printf("%d ", a[i][j]);
}
void main()
{
    int a[2][2] = {0};
    f(a);
}

Question Number 88

Give the output of the following code snippet :
void main()
{
    int arry[10]= {1,2,3,4};
    printf("%d",*(arry+6));
}

Question Number 89

Give the output of the following code snippet :
struct node
{
    int data;
    struct node *next;
}*head;

void func( int num )
{
    struct node *temp2;
    temp2=(struct node *)malloc(sizeof(struct node));
    temp2->data=num;
    temp2->next=head;
    head=temp2;
}

void  display(struct node *r)
{
    r=head;
    while(r->next!=NULL)
    {
        printf("%d ",r->data);
        r=r->next;
    }
}

void main()
{
    struct node *n;
    func(100);
    func(200);
    func(300);
    display(n);
}

Question Number 90

Give the output of the following code snippet :
int main()
{
    int a = 20, b = 10,c=2;
    _asm
    {
        mov eax,dword ptr[a]
        mov ebx,c
        push a
        push b
        mov ecx,dword ptr[c]
        pop a
        sub eax,ecx
        xor ebx,ecx
        inc ebx
        mov a,eax
        pop b
        mov b,ebx

    }
    printf("%d %d",a,b);
}

Question Number 91

Give the output of the following code snippet :
int main()
{
    int a = 20;
    int b = 20;

    if ((a < <  1) == (b * 2))
        printf("True ");
    else
        printf("False");
}

Question Number 92

Give the output of the following code snippet :
int main()
{
    int a=10, b=20,*ptr,*qtr;
    ptr=&a;
    qtr=&b;
    *ptr=b++;
    *qtr=*ptr+a;
    printf("%d %d %d", a,*ptr,*qtr);
    return 0;
}

Question Number 93

Give the output of the following code snippet :
void main()
{
    double a=100.25;
    double b=200.25;
    double c = ((a) == (b) ? (a++) : (b--));
    double d= ((a) >= (b) ? (++a) : (--b));

    printf("%.2f %.2f",c,d);
}

Question Number 94

Give the output of the following code snippet :
struct Vehicle
{
    int Id;
    char *name;

    struct Car
    {
        int Id;
        char *name;
    } Cobj;
};

void main()
{
    struct Vehicle *Vobj;
    Vobj->Cobj.Id=1001;
    strcpy(Vobj->Cobj.name,"Nano");
    printf("%s",Vobj->Cobj.name);
}

Question Number 95

Give the output of the following code snippet :
int main()
{
    char *p[1] = {"Hello"};
    printf("%s", (p)[1]);
    return 0;
}

Question Number 96

Give the output of the following code snippet :
int main()
{
    int i=3, *j, k;
    j = &i;
    printf("%d\n", i+*j);
    return 0;
}

Question Number 97

Give the output of the following code snippet :
int mod(int a, int b)
{
    return a % b;
}
void main()
{
    int (*fptr)()= &mod;
    printf("%d",(*fptr)(10,6));
}

Question Number 98

Give the output of the following code snippet :
typedef struct test
{
    int id;
} Test;

int main()
{
    Test t1;
    t1.id=10;
    printf("%d",t1.id);

}

Question Number 99

Give the output of the following code snippet :
union u
{
    struct
    {
        unsigned char x : 2;
        unsigned int y : 2;
    } p;

    int x;
};
int main()
{
    union u un;
    un.p.x = 2;
    printf("%d\n", un.p.x);
}

Question Number 100

Give the output of the following code snippet :
int main()
{
    const int x=200;
    int y;
    y=x++;
    int z=x+y;
    printf("%d",z);

}

Question Number 101

Give the output of the following code snippet :
void func(struct stud *stuobj);
struct stud
{
    int no;
    char name[3];
    stud *link;
};

void main()
{
    struct stud s= {101,"Jess"};
    func(&s);
}
void func(struct stud *stuobj)
{
    struct stud *s;
    s=stuobj;
    printf("%s",s->name);
}

Question Number 102

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])

{
    int a = 0, b =0, c=0,d=0;
    __asm
    {
        push 10
        push 20
        mov ebx,30
        mov eax, 40
        mov ecx,60
        push 50
        call label1
        mov a,eax
        mov b,ebx
        add esp, 12
        jmp Label2
        label1:

        mov eax, dword ptr[esp + 4]
        mov a, eax
        add a, ebx
        mov eax, dword ptr[esp + 8]
        mov b, eax
        mov eax, dword ptr[esp + 12]
        or edx,ecx
        mov c,eax
        add edx,ecx
        sub edx,10
        mov d,edx
        ret
    }
Label2:
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 103

Give the output of the following code snippet :
void main()
{
    int x=10,y=20;
    int z=x+y;
    int* const ptr=&x;
    printf("%d",*ptr);
}

Question Number 104

Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
void func1();


/* Test2.h */
static int value;
void func();

/* Test1.c */

#include"Test2.h"

void func()
{
    printf("Output = %d\n",value);
}

/* Test2.c */
#include"Test2.h"

void func1()
{
    printf ( "Output = %d\n", ++value );
    func();

}



/* Test3.c */

#include "Test1.h"
#include "Test2.h"

void main ()
{
    func();

}

Question Number 105

Give the output of the following code snippet :
typedef struct p *q;
struct p
{
    int x;
    char y;
    q ptr;
};
int main()
{
    struct p p = {10, 20, &p};
    printf("%d\n", p.ptr.x);
}

Question Number 106

Give the output of the following code snippet :
int(*funcptr) (char a);
int myfunc(char a)

{
    _asm
    {
        mov         byte ptr [a],48h
        mov         al,byte ptr [a]
        add         al,3
        mov         byte ptr [a],al
    }
    printf("%d",a);
    return 0;
}
int testCaller(int(*funcptr) (char a))
{
    _asm
    {
        push        7Ah
        call        dword ptr [funcptr]
        add         esp,4
    }
    return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
    testCaller(myfunc);
    return 0;
}

Question Number 107

Give the output of the following code snippet :
struct q
{
    char *name;
    struct q *next;
};
struct q *ptrary[10];
int main()
{
    struct q *p;
    p->name = "Hello";
    ptrary[0] = p;
    printf("%s\n", p->name);
    return 0;
}

Question Number 108

Give the output of the following code snippet :
struct point
{
    int x;
    float y;
};
void fun(struct point*);
int main()
{
    struct point p1[] = {1, 2, 3, 4, 5};
    fun(p1);
}
void fun(struct point p[])
{
    printf("%d %f\n", p->x, p[3].y);
}

Question Number 109

Give the output of the following code snippet :
struct node
{
    int data;
    struct node *next;
    struct node *prev;
}*head;

void func( int num )
{
    struct node *temp;
    temp=(struct node *)malloc(sizeof(struct node));
    temp->data=num;
    temp->next=head;
    temp->prev=NULL;
    while(head!=NULL)
        head=head->next;
    head=temp;


}

void  display()
{
    struct node *r;
    r=head->next;
    while(r!=NULL)
    {
        printf("%d ",r->data);
    }
}

void main()
{
    func(100);
    func(200);
    func(300);
    func(400);
    display();
}

Question Number 110

Give the output of the following code snippet :
struct node
{
    int data;
    struct node *next;
}*head=0;

void addtoLoc( int n,int num )
{
    struct node *temp2,*temp;
    temp2=head;
    if(temp2==NULL)
    {
        printf("Empty List");
        return;
    }
    for(int i=1; i< =n; i++)
        temp2=temp2->next;
    temp=(struct node *)malloc(sizeof(struct node));
    temp->data=num;
    temp->next=temp2->next;
    temp2->next=temp;
}

void  display(struct node *r)
{
    r=head;
    while(r!=NULL)
    {
        printf("%d ",r->data);
        r=r->next;
    }
}

void add( int num )
{
    struct node *temp;
    temp=(struct node *)malloc(sizeof(struct node));
    temp->data=num;
    temp->next=head;
    head=temp;
}
void main()
{
    struct node *n;
    add(100);
    add(200);
    add(300);
    addtoLoc(0,400);
    display(n);
}

Question Number 111

Give the output of the following code snippet :
int main()
{
    int a = 20;
    int b = 20;

    if ((a >> 1) == (a * 2))
        printf("True ");
    else
        printf("False");
}

Question Number 112

Give the output of the following code snippet :
int main()
{
    char *MemAlloc;
    MemAlloc = (char*)malloc(20 * sizeof(char) );
    strcpy( MemAlloc,"SourceLens");
    printf("%s",MemAlloc);
}

Question Number 113

Give the output of the following code snippet :
char sub1()
{
    return "HelloWorld";
}
void main()
{
    char* (*fptr)();
    fptr= &sub1;
    printf("%s",(*fptr)());
}

Question Number 114

Give the output of the following code snippet :
void main()
{
    int a=10,c=10,b=40;
    _asm
    {
        mov eax,40
        mov ebx,a
        sub eax,dword ptr[b]
        jbe Label2
        and eax,c
        mov b,eax
        Label2:
        mov ecx,dword ptr[a]
        cmp ecx,10
        je Label1
        and eax,50
        mov c,eax

    }
Label1:	printf("%d %d",b,c);
}

Question Number 115

Give the output of the following code snippet :
int main()
{
    char *a[1] = {"Hello"};
    printf("%s", a[0]);
    return 0;
}

Question Number 116

Give the output of the following code snippet :
int main()
{
    int ary[4] = {1, 2, 3, 4};
    printf("%d\n", *(ary+2));
}

Question Number 117

Give the output of the following code snippet :
void main()
{
    int a=10,c=20,b=-30;
    _asm
    {
        mov eax,40
        mov ebx,dword ptr[b]
        cmp eax,ebx
        jle Label2
        or eax,ebx
        mov b,eax
        Label2:
        mov ecx,dword ptr[a]
        sub ecx,ebx
        jz Label1
        or eax,ecx
        mov c,eax

    }
Label1:	printf("%d %d",b,c);
}

Question Number 118

Give the output of the following code snippet :
union p
{
    unsigned int x : 3;
    unsigned int y : 3;
};
int main()
{
    union p p;
    p.x = 2;
    p.y = 4;
    printf("%d %d",p.x, p.y);
}

Question Number 119

Give the output of the following code snippet :
union date
{
    unsigned int d;
    unsigned int m;
    unsigned int y;
};

int main()
{
    union date dt[] = {12, 10, 2000};
    printf("Date is %d/%d/%d", dt[0].d, dt[0].m, dt[0].y);
}

Question Number 120

Give the output of the following code snippet with the following command line arguments : >Test.c 100 200 300
int main(int argc, char *argv[])
{
    for(int i=0; i< argc; i++)
        printf("%s ", (argv[i]));
    return 0;
}

Question Number 121

Give the output of the following code snippet :
int func()
{
    int *ptr;
    int x=100;
    ptr=&x;
    return *ptr;
}
void main()
{
    int (*f[5])();
    f[1]=func;
    printf("%d",(*f)());
}

Question Number 122

Give the output of the following code snippet :
void main()
{
    char str1[15]="Hello World";
    char str[10]="Yellow";
    char str2[10]="\0World";
    strcat(str,str2);
    printf("%d",sizeof(str));
}

Question Number 123

Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
void func1();


/* Test2.h */
static int value = 100;
void func();

/* Test1.c */

#include"Test2.h"

void func()
{
    printf("Output = %d\n",value);
}

/* Test2.c */
#include"Test2.h"

void func1()
{
    printf ( "Output = %d\n", ++value );

}


/* Test3.c */

#include "Test1.h"
#include "Test2.h"

int value = 300;

void main ()
{
    func1();
    func();
}

Question Number 124

Give the output of the following code snippet :
struct
{
    char *name;
    union
    {
        char *sval;
    } u;
} symtab;
void main()
{
    symtab.u.sval="HelloWorld";
    printf("%s",symtab.u.sval);
}

Question Number 125

Give the output of the following code snippet :
void main()
{
    int row=2,col=2;
    int **arr;
    int i,j;
    arr=(int*)malloc(row*sizeof(int));
    for(i=0; i< row; i++)
        arr[i]=(int*)malloc(col*sizeof(int));
    for(i=0; i< row; i++)
    {
        for(j=0; j< col; j++)
        {
            arr[i][j]=i+j*i;
            printf("%d ",arr[i][j]);
        }
    }
}

Question Number 126

Give the output of the following code snippet : Assume address of p is 5000
int main()
{
    char *p;
    printf("%p ",p);
    p=p+1;
    printf("%p",p);
}

Question Number 127

Give the output of the following code snippet :
void main()
{
    int a = 50, b = 0, c;
    _asm
    {
        cmp         dword ptr[a], 32h
        jge         Label1
        mov         dword ptr[b], 14h
        mov         dword ptr[c], 1Eh
        jmp         Label2
        Label1 : mov         dword ptr[b], 28h
        mov         dword ptr[c], 32h
        Label2 :

    }
    printf("%d %d %d", a, b, c);
}

Question Number 128

Give the output of the following code snippet :
void main()
{
    char *str1="\0";
    int n=printf("%s",str1);
    if(n)
        str1="New Program";
    else
        printf("Hello World");
}

Question Number 129

Consider the given structure and state whether it is a self referencing structure :
struct node
{
    int x;
    struct node *next;
}*Head;

Question Number 130

Give the output of the following code snippet :
int main()
{
    int a = 10, b = 20, c;
    _asm
    {
        mov eax,a
        mov ebx,b
        add eax,ebx
        mul a
        mov b,ebx

    }
    printf("%d",a);
}

Question Number 131

Give the output of the following code snippet :
void fun(int p[4])
{
    int i = 10;
    p = &i;
    printf("%d ", p[0]);
}
int main()
{
    int ary[4] = {1, 2, 3, 4};
    fun(ary);
    printf("%d ", ary[0]);
}

Question Number 132

Give the output of the following code snippet :
void main()
{
    int x=10,y=20;
    int z=x+y;
    int const* ptr=&z;
    z++;
    printf("%d",*ptr);
}

Question Number 133

Give the importance of the following line of code from the given program: temp5=temp2->next; temp2 -> next=temp1; temp1->next=temp5;
void SortList()
{
    node *temp1,*temp2,*temp3,*temp4,*temp5;
    temp4=NULL;
    while(temp4!=Head->next)
    {
        temp3=temp1=Head;
        temp2=temp1->next;
        while(temp1!=temp4)
        {
            if(temp1->x > temp2->x)
            {
                if(temp1==Head)
                {
                    temp5=temp2->next;
                    temp2 -> next=temp1;
                    temp1->next=temp5;

                    Head = temp2;
                    temp3=temp2;
                }
                else
                {
                    temp5=temp2->next;
                    temp2 -> next=temp1;
                    temp1->next=temp5;

                    temp3->next = temp2;
                    temp3=temp2;
                }
            }
            else
            {
                temp3=temp1;
                temp1=temp1->next;
            }
            temp2=temp1->next;
            if(temp2 == temp4)
                temp4=temp1;
        }
    }
}

Question Number 134

Give the output of the following code snippet :
int main()
{
    int a = 15, b = 10, c=5;
    _asm
    {
        mov eax,a
        mov ebx,b
        mov edx,dword ptr[c]
        xor eax,ebx
        and  eax,edx
        inc edx
        mov dword ptr[a],eax
        mov dword ptr[b],edx
    }
    printf("%d %d",a,b);
}

Question Number 135

Give the output of the following code snippet :
int sum(char* first,...)
{
    int sum=0, count=0,i;
    va_list marker;
    va_start(marker,first);
    do
    {
        i=va_arg(marker,float);
        printf("%d ",i);
    }
    while(i!=0);
    va_end(marker);
    return sum;
}
int main(int argc, char *argv[])
{
    sum("Test",2,4.4,6,-1);
}

Question Number 136

Give the output of the following code snippet :
void main()
{
    int a = 10;
    int b = 20;
    int c = 30;
    int d = 0;
    __asm
    {
        mov eax,c
        push eax
        mov eax,b
        push eax
        mov eax,a
        push eax
        mov eax,Func
        call eax
        mov ebx,End
        jmp ebx
        Func :
        add esp,4
        pop eax
        mov a, eax
        pop eax
        mov b, eax
        pop eax
        mov c,eax
        sub esp,0x10
        ret
        End : add esp, 0x10
    }
    printf("%d %d %d", a, b,c);
}

Question Number 137

Give the output of the following code snippet :
int main()
{
    int a,b,c=20;
    _asm
    {
        mov dword ptr[a],15
        mov dword ptr[b],10
        or ebx,dword ptr[c]
        mov eax,dword ptr[c]
        xor ebx,eax
        inc ebx
        mov a,ebx
    }
    printf("%d",a);
}

Question Number 138

Give the output of the following code snippet :
int main()
{

    int arry[10]= {1,2,3,4,5,6};
    int x=arry[5];
    x++;
    int y=6[arry];
    y--;
    int z=x+y;
    z--;
    printf("%d",++z);

}

Question Number 139

Give the output of the following code snippet :
struct student
{
    char a[10];
};
void main()
{
    struct student s[] = {"Hello", "World"};
    printf("%d", sizeof(s));
}

Question Number 140

Give the output of the following code snippet :
typedef int(*fptr)(int a);
typedef struct
{
    int a;
    fptr fpt[10];
} fp;

int fun(int a)
{
    int sum = 0;
    _asm
    {
        mov         dword ptr[a], 24h
        mov         eax, dword ptr[a]
        add         eax, 0Ah
        mov         dword ptr[a], eax
        mov         ecx, dword ptr[sum]
        and         ecx, dword ptr[a]
        mov         dword ptr[sum], ecx
    }
    printf("%d", sum);
    return 0;
}

int _tmain()
{
    fp myS;
    myS.fpt[1] = fun;
    _asm
    {
        push        5Ah
        mov         ecx, 4
        shl         ecx, 0
        mov         edx, dword ptr[ebp + ecx - 28h]
        call        edx
        add         esp, 4
    }
}

Question Number 141

Give the output of the following code snippet :
char i;
void main()
{
    (int)i;
    printf("%d",sizeof(i));
}

Question Number 142

Give the output of the following code snippet :
int main()
{
    int a = 10, b = 20,c=5;
    _asm
    {
        mov eax,dword ptr[a]
        mov ebx,dword ptr[b]
        and ebx,c
        or  ecx,ebx
        mov c,ecx

    }
    printf("%d",c);
}

Question Number 143

While passing a two dimensional array as argument to a function, which of the following parameters is optional?
< NIL>

Question Number 144

Give the output of the following code snippet :
void print(char *str,...)
{
    int i;
    va_list marker;
    va_start(marker,str);
    i=va_arg(marker,int);
    i=va_arg(marker,int);
    i=va_arg(marker,int);
    printf("%d",i);
    va_end(marker);
}
int main()
{
    print('A',2,-1);
}

Question Number 145

Give the output of the following code snippet :
void main()
{
    int a=40,c=40,b=10;
    _asm
    {
        mov eax,40
        mov ebx,dword ptr[c]
        sub eax,ebx
        ja Label2
        shl eax,2
        and eax,dword ptr[a]
        mov b,eax
        Label2:
        mov ecx,dword ptr[a]
        sub ecx,ebx
        je Label1
        and eax,ecx
        mov c,eax

    }
Label1:	printf("%d %d",b,c);
}

Question Number 146

Give the output of the following code snippet :
int main()
{
    enum Days {SUN,MON,TUES,WED,THURS,FRI,SAT};
    Days day;
    printf("%d %d",sizeof(Days),WED++ + --THURS);
}

Question Number 147

Give the output of the following code snippet :
char *func()
{
    char *str=(int*)malloc(20*sizeof(char));
    strcpy(str,"Hello World");
    return str;

}
void main()
{
    char *s;
    s=func();
    printf("%s",s);
}

Question Number 148

Give the output of the following code snippet :
void main()
{
    char arry[10]="Hello";
    char str[15]="World";
    const char* ptr=str;
    str[0]='Y';
    printf("%s",str);
}

Question Number 149

Which of the following are valid pointer operations in C?
< NIL>

Question Number 150

Give the output of the following code snippet :
void main()
{
    int a=100;
    int b=200;
    char *c="12.50";
    char str[10],st[10];
    int x;
    float val=10.25;
    float res=atof(c)+val;
    itoa(100,st,16);
    printf("%s %.2f",st,c);
}

Question Number 151

Give the output of the following code snippet :
struct
{
    char *name;
    union
    {
        char *sval;
    } u[5];
} symtab[10];
void main()
{
    symtab[0].u[0].sval="HelloWorld";
    printf("%s",symtab[0].u[1].sval);
}

Question Number 152

Give the output of the following code snippet :
void main()
{
    int x, *ptr1;
    _asm
    {
        mov         dword ptr[x], 14h
        lea         eax, [x]
        mov         dword ptr[ptr1], eax
        mov         ecx, dword ptr[x]
        add         ecx, 1
        mov         dword ptr[x], ecx
    }
    printf("%d ", *ptr1);
}

Question Number 153

Give the output of the following code snippet :
const int* func(int i)
{
    int x=i;
    const int *ptr=&x;
    return (ptr);
}

void main()
{
    int a=10,b=20;
    const int *qtr=func(a);
    qtr=&b;
    b++;
    printf("%d",*qtr);
}

Question Number 154

Give the output of the following code snippet :
struct student
{
    char *c;
    struct student *point;
};
void main()
{
    static struct student s[]= {"Hello",s+1,"World",s+2};
    struct student *m=s;
    printf("%s",++(m->c));
}

Question Number 155

Give the output of the following code snippet : What are the contents of the file 'Test.txt' after the code is executed?
void main()
{
    char x;
    FILE *fp;
    fp=fopen("Test.txt","w+");
    fprintf("%s","Hello","World");
    fclose(fp);
}

Question Number 156

Give the output of the following code snippet : Assume the array begins at the following address 5000
int main()
{

    int arr[5]= {20,10,5,0,1};
    int arry2[]= {*arr,*arr+2,*arr+3,*arr+4};
    printf("%u %u",arr+1,&arr+1);

}

Question Number 157

Give the output of the following code snippet :
void main()
{
    typedef unsigned int uint;
    typedef float fl;
    uint x=100,y=200;
    fl p=100.25,q=200.50;
    unsigned int a=300,b=400;
    int z = x+y-a/b;
    float w= q/p;
    float v=z/w;
    printf("%.2f",v);
}

Question Number 158

Give the output of the following code snippet :
int main()
{
    float *Pa1,*Pa2,*Pa3;
    float a1=10.25,b1=12.5;
    Pa1=&a1;
    Pa2=&b1;
    *Pa3=*Pa1**Pa2;
    printf("%f",*Pa3);
}

Question Number 159

Give the output of the following code snippet :
void main()
{
    int arr[]= {0x1,0x2,0x3,0x4};
    int i=5,j=3;
    int x=10;
    while(i>=0)
    {
        if( j && arr[i] || ~j)
            x++;
        i--;
    }
    printf("%d",x);
}

Question Number 160

Consider the following lines of code from the given program : What does temp2 store? temp3=temp2; temp2=temp1; temp1=temp1->next;
void ReverseList()
{
    node *temp1,*temp2,*temp3;
    temp1=Head;
    temp2=NULL;
    while(temp1!=NULL)
    {
        temp3=temp2;
        temp2=temp1;
        temp1=temp1->next;
        temp2->next=temp3;
    }
    Head=temp2;
}

Question Number 161

Give the output of the following code snippet :
union p
{
    int x;
    char y;
};
int main()
{
    union p p1[] = {1, 92, 3, 96};
    union p *ptr1 = p1;
    printf("%d\n",p1[1].x);
}

Question Number 162

Give the output of the following code snippet :
int main()
{
    int a = 10, b = 20,c=5;
    _asm
    {
        mov eax,a
        mov ebx,b
        xor eax,dword ptr[c]
        mov b,eax

    }
    printf("%d",b);
}

Question Number 163

Give the output of the following code snippet :
int main()
{
    int a = 10, b = 20,c=5;
    _asm
    {
        mov eax,a
        mov ebx,b
        or ebx,c
        mov ecx,eax
        and ecx,ebx
        mov c,ecx

    }
    printf("%d",c);
}

Question Number 164

Give the output of the following code snippet :
void disp(int num,...)
{
    print(num,...);
}
void print(int num,...)
{
    int i,k;
    float j;
    va_list marker;
    va_start(marker,num);
    j=va_arg(marker,double);
    printf("%.2f ",j);
    va_end(marker);
}
int main(int argc, char *argv[])
{
    print(1,2.2,3.3,4.4);
}

Question Number 165

Consider the following lines of code from the given program : What does temp3 store? temp3=temp2; temp2=temp1; temp1=temp1->next;
void ReverseList()
{
    node *temp1,*temp2,*temp3;
    temp1=Head;
    temp2=NULL;
    while(temp1!=NULL)
    {
        temp3=temp2;
        temp2=temp1;
        temp1=temp1->next;
        temp2->next=temp3;
    }
    Head=temp2;
}

Question Number 166

Give the output of the following code snippet :
int main()
{
    int i, *j, k;
    _asm
    {
        mov         dword ptr[i], 1Ah
        lea         eax, [i]
        mov         dword ptr[j], eax
        mov         ecx, dword ptr[j]
        mov         edx, dword ptr[ecx]
        sub         edx, 5
        mov         eax, dword ptr[j]
        mov         dword ptr[eax], edx
        mov         ecx, dword ptr[j]
        mov         edx, dword ptr[i]
        imul        edx, dword ptr[ecx]
        mov         eax, dword ptr[j]
        sub         edx, dword ptr[eax]
        mov         dword ptr[k], edx
    }
    printf("%d\n", k);
}

Question Number 167

Give the output of the following code snippet :
void fun(int *);
int main()
{
    int i = 10, *p = &i;
    fun(&i);
}
void fun(int *p)
{
    printf("%f\n", *p);
}

Question Number 168

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])

{
    int a = 20, b = 30, c=0,d=0;
    __asm
    {
        push 10
        push 20
        push 30
        push 40
        mov ebx,a
        mov eax, 40
        mov ecx,label1
        call ecx
        add esp,0x10
        mov edx,Label2
        mov dword ptr[c],edx
        jmp dword ptr[c]
        label1:
        add esp,4
        pop eax
        mov a, eax
        pop eax
        mov b, eax
        pop eax
        mov c,eax
        pop eax
        mov d,eax
        sub esp,20
        ret

        Label2:mov c,ebx
        mov d,eax

    }
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 169

Give the output of the following code snippet :
void main()
{
    int x=10,y=20,arr[3],i;
    for(i=0; i< 3; i++)
    {
        arr[i]=++x;
        if(arr[i]==x || arr[i]==++x)
        {
            printf("Hello");
            break;
        }
        else
            printf("World");
    }

}

Question Number 170

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])

{
    int a = 0, b =0, c=0,d=0;
    __asm
    {
        push 10
        push 20
        mov ebx,30
        mov eax, 40
        mov ecx,60
        push 50
        call label1
        mov a,eax
        mov b,ebx
        add esp, 12
        jmp Label2
        label1:
        mov d,eax
        mov eax, dword ptr[esp + 4]
        mov a, eax
        add a, ebx
        mov eax, dword ptr[esp + 8]
        mov b, eax
        mov eax, dword ptr[esp + 12]
        or ebx,ecx
        xor edx,ecx
        mov c,eax
        mov d,edx
        ret
    }
Label2:
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 171

Consider the given code : Which of the following statements in the code is used to indicate that it is a self referencing structure?
struct node
{
    int x;
    struct node *next;
}
node *Head;

Question Number 172

Give the output of the following code snippet :
void main()
{
    int i = 0, a = 10;
    _asm
    {
        Label2:  cmp         dword ptr[i], 0
        jle         Label1
        mov         eax, dword ptr[a]
        add         eax, 5
        mov         dword ptr[a], eax
        Label1 : mov         ecx, dword ptr[i]
        add         ecx, 3
        mov         dword ptr[i], ecx
        cmp         dword ptr[i], 9
        jne         Label2
    }

    printf("%d", a);
}

Question Number 173

Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
static int value;
void func1();


/* Test2.h */
extern int value;
void func();

/* Test1.c */

#include "Test1.h"

void func()
{
    printf("Output = %d\n",value);
}

/* Test2.c */
#include "Test1.h"

void func1()
{
    printf ( "Output = %d\n", ++value );

}


/* Test3.c */
#include "Test1.h"
#include "Test2.h"

void main ()
{
    func1();
    func();
}

Question Number 174

Give the output of the following code snippet :
int main()
{
    int a[5][5] = {{1, 2, 3}, {5, 2, 3}};
    printf("%d",*a[]+1);
}

Question Number 175

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])

{
    int a = 0, b =0, c=0;
    __asm
    {
        push 10
        push 20
        mov ebx,30
        mov eax, 40
        mov ecx,label1
        call ecx
        add esp, 8
        mov ecx,Label2
        jmp ecx
        label1:
        add esp,4
        mov eax, dword ptr[esp + 4]
        mov a, eax
        pop eax
        mov b, eax
        mov eax, dword ptr[esp + 12]
        mov c,ebx
        sub esp,8
        ret
    }
Label2:
    printf("%d %d %d", a, b, c);

}

Question Number 176

Give the output of the following code snippet :
int func()
{
    int **p;
    int *q;
    int x=100;
    p=&q;
    q=&x;
    return *q;
}
void main()
{
    int (*f)();
    f=func;
    printf("%d",f());
}

Question Number 177

Give the output of the following code snippet :
void main()
{
    char str1[15]="Hello World";
    char str[10]="Yellow";
    char str2[10]="\0World";
    strcat(str,str2);
    printf("%d %c",strlen(str),"HelloWorld"[0]);
}

Question Number 178

Give the output of the following code snippet :
int main()
{
    int a = 20, b = 10,c=2;
    _asm
    {
        mov eax,100
        push eax
        push ebx
        mov ecx,esp
        sub ebx,ecx
        pop ebx,eax
        mov a,eax
        mov b,ecx
    }
    printf("%d %d",a,b);
}

Question Number 179

Give the output of the following code snippet :
int print(int num,...)
{
    int sum=0, count=0,i,j;
    va_list marker;
    va_start(marker,num);
    for(i=0; i< num+1; i++)
    {
        j=va_arg(marker,int);
        printf("%d ",j);
    }
    va_end(marker);
    return sum;
}
int main(int argc, char *argv[])
{
    print(3,4,6,-1);
}

Question Number 180

Give the output of the following code snippet :
int main()
{

    int (*p)[5];
    int a[][5]= {1,2,3,4,5,6};
    p=a;
    int *q;
    q=(int*)a;
    printf("%d %d %d",**p+3,*q+5,**a);

}

Question Number 181

Give the output of the following code snippet :
void *f()
{
    int*p;
    int x=100;
    p=&x;
    return p;
}
void main()
{
    void *ptr;
    ptr=f();
    printf("%d",*(int*)ptr);
}

Question Number 182

Give the output of the following code snippet :
struct student
{
    char *c;
    struct student *point;
};
void main()
{
    struct student s;
    printf("%d", sizeof(s));
}

Question Number 183

Give the output of the following code snippet :
void func(struct stud *stuobj);
struct stud
{
    int no;
    int no2;
};

void main()
{
    struct stud *s=(stud*)malloc(sizeof(stud));
    s->no=1001;
    func(s);
}
void func(struct stud *stuobj)
{
    struct stud *s;
    s=stuobj;
    printf("%d",s->no);
}

Question Number 184

Give the output of the following code snippet :
struct temp
{
    int a;
} s;
void change(struct temp s)
{
    s.a = 1;
}
void main()
{
    s.a = 10;
    change(s);
    printf("%d\n", s.a);
}

Question Number 185

Give the output of the following code snippet :
void main()
{
    typedef unsigned int uint;
    typedef float fl;
    uint x=100,y=200;
    fl p=100.25,q=200.50;
    unsigned int a=300,b=400;
    int z = x+y-a/b;
    float w= q/p;
    float v=z/w;
    printf("%d",z);
}

Question Number 186

Give the output of the following code snippet :
void main()
{
    struct student
    {
        int age;
        int id;
    };
    struct student s= {20,1001};
    int ch;
    char str[10];
    FILE *fp,*fp1;
    fp=fopen("Test.txt","r");
    fwrite(&s,sizeof(s),1,fp);
    fclose(fp);
    fp1=fopen("Test.txt","r");
    struct student s1;
    fread(&s1, sizeof(s1), 1, fp1);
    printf("%d",s1.age);
    fclose(fp1);
}

Question Number 187

Give the output of the following code snippet :
int main()
{
    int x=20,y=10,z=20;
    int a= !x==10 && z==30;
    int b= x&y;
    int c= x-- > y++;
    printf("%d %d %d",a,b,c);
}

Question Number 188

Give the output of the following code snippet : Assume the contents of the file 'Test.txt' is "Hello World".
void main()
{
    FILE *fp,*fp1;
    char x[20];
    fp = fopen("Test.txt","r");
    int i=0;
    while(fgets(x,8,fp)!=NULL)
    {
        puts(x);
    }
    fclose(fp);

}

Question Number 189

Give the output of the following code snippet who's solution configuration has been set to the DEBUG mode :
int main()
{
    int a = 200, b = 100, c = 2;
    _asm
    {
        mov eax, esp
        mov ebx, 10
        push eax
        push ebx
        mov ecx, esp
        mov ebx, dword ptr[b]
        sub ecx, eax
        mov a, ecx
        mov b, ebx
        add esp,8

    }
    printf("%d %d", a, b);
}

Question Number 190

Give the output of the following code snippet :
int sum(int first,...)
{
    int sum=0, count=0,i=first;
    va_list marker;
    va_start(marker,first);
    while(i!=-1)
    {
        sum+=i;
        count++;
        i=va_arg(marker,int);
    }
    va_end(marker);
    return sum;
}

int main(int argc, char *argv[])
{
    printf("%d",sum(2,3,4,5,6,-1));
}

Question Number 191

Consider the given structure and state whether it is an example of a doubly linked list:
struct node
{
    int x;
    struct node *prev;
    struct node *next;

}*Head;

Question Number 192

Give the output of the following code snippet :
void main()
{
    char str[]="Hello world";
    char *str1="Hello world";
    if(str==str1)
        printf("%s",str+2);
    else
        printf("%s",str1+5);
}

Question Number 193

Give the output of the following code snippet :
typedef struct student
{
    char a[10];
} stu;
void main()
{
    struct st;
    st.a = "Jenn";
    printf("%s", st.a);
}

Question Number 194

Give the output of the following code snippet :
int sum(int first,...)
{
    int sum=0, count=0,i=first;
    va_list marker;
    va_start(marker,first);
    while(i!=-1)
    {
        sum+=i;
        count++;
        i=va_arg(marker,int);
    }
    va_end(marker);
    return sum;
}


int main(int argc, char *argv[])
{
    printf("%d",sum(2,3,4,1));
}

Question Number 195

Give the output of the following code snippet :
int main()
{
    int *MemAlloc;
    MemAlloc = (char*)malloc(20* sizeof(char));
    strcpy( MemAlloc,"Hello");
    printf("%s",MemAlloc+1);
}

Question Number 196

Give the output of the following code snippet :
int main()
{
    int *p = (int *)2;
    int *q = (int *)3;
    printf("%d", p + q);
}

Question Number 197

Give the output of the following code snippet :
int main()
{
    char str[15] = "Hello World";
    char ch = 'L';
    strnset(str,'L', 5);
    printf("%s ", str);
    return 0;
}

Question Number 198

Give the output of the following code snippet :
int main()
{
    int a = 2000;
    int b = 1000;

    int c = a >> 3;
    int d = b >> 2;

    if(c == d)
        printf("True");
    else
        printf("False");

}

Question Number 199

Give the output of the following code snippet :
int main()
{
    int (*ptr);
    int val=10;
    ptr=val;
    printf("%d",*ptr);
}

Question Number 200

Give the output of the following code snippet :
struct node
{
    int data;
    struct node *next;
    struct node *prev;
}*head;

void func( int num )
{
    struct node *temp,*temp2;
    if (head== NULL)
    {
        temp=(struct node *)malloc(sizeof(struct node));
        temp->data=num;
        temp->next=NULL;
        temp->prev=NULL;
        head=temp;
    }
    else
    {
        temp=head;
        while (temp->next!=NULL)
            temp=temp->next;
        temp2=(struct node *)malloc(sizeof(struct node));
        temp2->data=num;
        temp2->next=NULL;
        temp->next=temp2;
        temp2->prev=temp;
    }

}


void  display()
{
    struct node *r;
    r=head;
    while(r!=NULL)
    {
        printf("%d ",r->data);
        r=r->next;
    }
}

void main()
{
    func(100);
    func(200);
    func(300);
    func(400);
    display();
}

Question Number 201

Give the output of the following code snippet :
struct Vehicle
{
    int Id;
    char *name;

    struct Car
    {
        int Id;
        char *name;
    } Cobj;
};

void main()
{
    struct Vehicle Vobj;
    Cobj.Id=1001;
    printf("%d",Cobj.Id);
}

Question Number 202

Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
static int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
void func()
{
    value=200;
    printf ( "Output = %d\n", ++value );
}

/* Test2.c */
#include "Test1.h"

void func1()
{
    printf ( "Output = %d\n", ++value );

}


/* Test3.c */

#include "Test1.h"

void main ()
{
    func1();
    func();
}

Question Number 203

Give the output of the following code snippet :
int main()
{
    int i, *p, q;
    _asm
    {
        mov         dword ptr[i], 0Ah
        lea         eax, [i]
        mov         dword ptr[p], eax
        mov         ecx, dword ptr[p]
        mov         edx, dword ptr[ecx]
        sub         edx, 10
        add			eax,edx
        mov         eax, dword ptr[p]
        mov         dword ptr[eax], edx
        mov         ecx, dword ptr[p]
        mov         edx, dword ptr[ecx]
        add         edx, 0Ah
        mov         dword ptr[q], edx
        mov         eax, dword ptr[p]
        add         eax, 10
        mov         dword ptr[p], eax
    }
    printf("%d", q);
}

Question Number 204

Give the output of the following code snippet :
void main()
{
    char *str1="%s";
    char str[]="Hello World";
    printf(str1,str+1);
}

Question Number 205

Which of the following operators is used to access the address of an object?
< NIL>

Question Number 206

Give the output of the following code snippet :
int main()

{
    int i = 3, a = 10, j = 5;
    _asm
    {
        Label3:   cmp         dword ptr[i], 0
        je          Label1

        mov         eax, dword ptr[a]
        add         eax, dword ptr[j]
        mov         dword ptr[a], eax
        mov         ecx, dword ptr[j]
        add         ecx, 1
        mov         dword ptr[j], ecx
        mov         edx, dword ptr[i]
        sub         edx, 1
        mov         dword ptr[i], edx
        cmp         dword ptr[i], 2
        jne         Label2
        jmp         Label1
        Label2 : jmp         Label3

    }
Label1:
    printf("%d", a);
}

Question Number 207

Give the output of the following code snippet :
void main()
{
    char s1[]="Hello";
    char *s2=(char*)malloc(sizeof(s1));
    int b=200;
    char str[20];
    sprintf(s2,"%.*s",8,s1);
    puts(s2);
}

Question Number 208

Give the output of the following code snippet :
int main()
{
    float x = 0.3;
    int y=10;
    if (x <  0.3f)
        printf("%d %d %d",sizeof(x),sizeof(0.3),sizeof(0.3f));
    else
        printf("Hello World");
}

Question Number 209

Give the output of the following code snippet :
void print(int num,...)
{
    int i,k;
    float j;
    va_list marker;
    va_start(marker,num);
    j=va_arg(marker,float);
    printf("%.2f ",j);
    va_end(marker);
}
int main(int argc, char *argv[])
{
    print(10,2,3.3,4.4);
}

Question Number 210

Give the output of the following code snippet :
union Test
{
    char str[20];
};

int main()
{
    union Test st1, *st2;
    strcpy(st1.str, "Hello");
    st2 = st1;
    st1.str[0] = 'J';
    printf("%s",st2.str);
}

Question Number 211

Give the output of the following code snippet :
int main()
{
    int a = 20, b = 10,c=2;
    _asm
    {
        mov eax,esp
        mov ebx,100
        push ebx
        mov ecx,esp
        sub eax,ecx
        or ebx,ecx
        inc ebx
        pop ebx
        mov a,eax
        mov b,ebx

    }
    printf("%d %d",a,b);
}

Question Number 212

Give the output of the following code snippet :
struct student
{
    int mark1;
    int mark2;

};
void main()
{
    struct student stud= {100,95};
    int *s;
    s=(int*)&stud;
    printf("%d",*(s+1));
}

Question Number 213

Give the output of the following code snippet :
void main()
{
    char str1[15]="Hello World";
    char str[10]="Yellow";
    char str2[10]="\0World";
    strcat(str,str2);
    printf("\\n");
    printf("%d %c",strlen(str));
}

Question Number 214

Give the output of the following code snippet :
void func(char *s)
{
    printf("%s",s);;
}
void main()
{
    char str[]="Hello World";
    char *str1="Hello world";
    str="New Program";
    func(str);
}

Question Number 215

Give the output of the following code snippet :
void func(char **a)
{
    printf("%s",*(a+5));
}
void main()
{
    char *str[15]= {"This","is","a","Hello","World","Program"};
    char *x;
    x=str[4];
    str[4]=str[5];
    str[5]=x;
    func(str);
}

Question Number 216

Give the output of the following code snippet :
void main()
{
    int a=20,c=50,b=30;
    _asm
    {
        mov eax,20
        mov ebx,a
        sub eax,dword ptr[c]
        jc Label2
        mov b,eax
        Label2:
        mov ecx,dword ptr[a]
        cmp eax,ecx
        jne Label1
        or eax,30
        mov c,eax

    }
Label1:	printf("%d %d",b,c);
}

Question Number 217

Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */

int value = 300;

void func();

/* Test1.c */

void func()
{
    int value = 200;
    printf ( "Output = %d", value );

}

/* Test2.c */

#include"Test1.h"

void main ()
{
    func();
    printf ( "Output = %d\n", value );
}

Question Number 218

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 0, b = 0;
    __asm
    {
        call Label2
        mov a, 100
        call Label2
        mov  eax, a
        cmp eax,200
        jle End

        Label2 : mov b, 200
        ret
        Label3:  mov a,200
        ret
        End : mov b,300
    }
    printf("%d %d", a, b);
}

Question Number 219

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 10, b = 10,c=10,d=10;
    __asm
    {
        mov eax,Label1
        mov dword ptr[c],eax
        call ebx
        mov ebx,Label2
        mov ecx,100
        jmp ebx
        Label1 :
        mov a, ecx
        mov d, 50
        ret
        Label2 : mov b,100
        mov c,300
    }
    printf("%d %d %d %d", a,b,c,d);
}

Question Number 220

Give the output of the following code snippet :
struct stud
{
    int age;
    char *name;
}*stud[10];
void main()
{
    printf("%d",sizeof(stud));
}

Question Number 221

Give the output of the following code snippet :
void print(...)
{
    int i;
    va_list marker;
    va_start(marker,int);
    do
    {
        i=va_arg(marker,int);
        printf("%d ",i);
    }
    while(i!=6);
    va_end(marker);
}
int main(int argc, char *argv[])
{
    print("Test",2,4,'D',-1);
}

Question Number 222

Give the output of the following code snippet :
void main()
{
    int arr[]= {10,20,30,40};
    int i=5,j=3;
    int x=10;
    while(i>=1)
    {
        if( j & arr[i])
            x++;
        i--;
    }
    printf("%d",x);
}

Question Number 223

Give the output of the following code snippet :
struct st
{
    int x;
    struct st next;
};

int main()
{
    struct st temp;
    temp.x = 10;
    temp.next = temp;
    printf("%d", temp.next.x);
    return 0;
}

Question Number 224

Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
void func1(int);
int arg = 10;


/* Test2.h */
static int value;
void func(int);

/* Test1.c */

#include"Test2.h"
void func1(int);
void func(int arg)
{
    value = 200;
    func1(arg);
    printf("Output = %d\n",arg+value);
}

/* Test2.c */
#include"Test2.h"

void func1(int arg)
{
    value = 100;
    printf ( "Output = %d\n", arg+value );

}



/* Test3.c */

#include "Test1.h"
#include "Test2.h"

void main ()
{
    func(arg);
}

Question Number 225

Give the output of the following code snippet :
int main()
{
    int i=10,*p;
    p=&i;
    ++*p;
    printf("%d",*p);
}

Question Number 226

Give the output of the following code snippet :
int main()
{
    typedef char char_arry[6];
    char_arry arry= {10,20,30,'a','b','c'};
    int i=0;
    while(i!=6)
    {
        printf("%d  ",arry[i]);
        i+=2;
    }
}

Question Number 227

Give the output of the following code snippet :
int main()
{
    float x=0.3,y=10,z=20;
    if( x == 0.3f)
        printf("%.2f",y+z);
    else
        printf("%.2f",z-y);
}

Question Number 228

Give the output of the following code snippet :
int main()
{
    char *str = "Hello";
    char *ptr = "World";
    str = ptr;
    printf("%s %s\n", str, ptr);
}

Question Number 229

Give the output of the following code snippet :
void main()
{
    char arry[10]="Hello";
    char str[15]="World";
    char* const ptr=str;
    *str='Y';
    printf("%s",str);
}

Question Number 230

Give the output of the following code snippet with the following command line arguments : >Test.c Hello World
int main(int argc, char *argv[])
{

    printf("%s\n", argv[argc-2]);
    return 0;
}

Question Number 231

Give the output of the following code snippet :
void main()
{
    int i = 0, a = 10;
    _asm
    {
        mov         dword ptr[i], 0
        jmp         Label1
        Label4 : mov         eax, dword ptr[i]
        add         eax, 1
        mov         dword ptr[i], eax
        Label1 : cmp         dword ptr[i], 3
        jge         Label2

        cmp         dword ptr[i], 1
        jle         Label3

        mov         ecx, dword ptr[a]
        add         ecx, 2
        mov         dword ptr[a], ecx


        Label3 : jmp         Label4

    }
Label2: printf("%d %d", a, i);
}

Question Number 232

Give the output of the following code snippet :
struct p
{
    int x;
    char y;
    struct p *ptr;
};
int main()
{
    struct p t = {1, 2, &t};
    printf("%d\n", t.ptr.y);
    return 0;
}

Question Number 233

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 10, b = 10,c=10,d=10;
    __asm
    {
        mov eax,Label1
        call eax
        mov ebx,Label2
        mov ecx,10
        mov edx,25
        cmp edx,ecx
        jz Label2

        Label1 :
        mov a, 20
        mov d, 10
        mov b,edx
        ret
        Label2 :
        mov c,300
        mov a,50
    }
    printf("%d %d %d %d", a,b,c,d);
}

Question Number 234

Give the output of the following code snippet :
int main()
{
    int a=40, b=50, c,d;
    c = (a == 10 && b != 30);
    c= a++ + b-- / ++c;
    d= ++a + ++b + --c;
    printf("%d %d",c,d);
    return 0;
}

Question Number 235

Give the output of the following code snippet with the following command line arguments : >Testfile.c one two three
/* Testfile.c */

int main(int argc, char *argv[])
{
    for(int i=1; i< argc; i++)
        printf("%s ", argv[i]);
    return 0;
}

Question Number 236

Consider the given structure and state whether it is a self referencing structure :
struct node
{
    int x;
    int *next;
};

Question Number 237

Give the output of the following code snippet :
void func(int *val)
{
    *val+=10;
}

void main()
{
    const int arry[10]= {1,2,3,4,5};
    func(&arry[0]);
    char str[15]="Hello World";
    arry[2]=10;
    str[0]='Y';
    printf("%d %s",arry[2]+arry[0],str);
}

Question Number 238

Give the output of the following code snippet :
char *func()
{
    char *str;
    strcpy(str,"Hello World");
    return str;

}
void main()
{
    char *s;
    s=func();
    printf("%s",s);
}

Question Number 239

Give the output of the following code snippet :
union Test
{
    char str[20];
};

int main()
{
    union Test st1, *st2;
    strcpy(st1.str, "Hello");
    st2 = st1;
    st1.str[0] = 'J';
    printf("%s",st2->str);
}

Question Number 240

Give the output of the following code snippet :
void print(int num, ...)
{
    char *str;
    va_list ptr;
    va_start(ptr, num);
    str = va_arg(ptr, char *);
    printf("%s ", str);
}
int main()
{
    print(1, "Hola", "Hi", "Hello");
    return 0;
}

Question Number 241

Give the output of the following code snippet :
void main()
{
    int a=100;
    int b=200;
    char str[10];
    int x;
    itoa(64,str,16);
    printf("%s ",str);
}

Question Number 242

Give the output of the following code snippet :
int main()
{
    int a = 10, b = 20, c;
    _asm
    {
        mov eax,a
        mov ebx,b
        add eax,ebx
        div ebx
        add eax,ebx
        mov a,eax
        mov b,ebx

    }
    printf("%d",a);
}

Question Number 243

Give the output of the following code snippet :
int main()
{
    float x=10.00;
    double y=10.00;
    if( x == y)
        printf("%.2e  %d",x,(int)x);
    else
        printf("%g %d",y,(int)y);
}

Question Number 244

Consider the given lines of code : When is the else{} part of the code executed?
void add( int num )
{
    struct node *temp,*temp2;
    if (head== NULL)
    {
        temp=(struct node *)malloc(sizeof(struct node));
        temp->data=num;
        temp->next=NULL;
        head=temp;
    }
    else
    {
        temp=head;
        while (temp->next!=NULL)
            temp=temp->next;
        temp2=(struct node *)malloc(sizeof(struct node));
        temp2->data=num;
        temp2->next=NULL;
        temp->next=temp2;
    }

}

Question Number 245

Give the output of the following code snippet :
struct point
{
    int x;
    int y;
};
void fun(struct point*);
int main()
{
    struct point p1[]  =  {1, 2, 3, 4};
    fun(p1);
}
void fun(struct point p[])
{
    printf("%d\n", p[1].x);
}

Question Number 246

Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */

int value = 100;
void func();

/* Test1.c */

int value = 200;
void func()
{
    printf ( "Output = %d", value );

}

/* Test2.c */

#include"Test1.h"

void main ()
{
    printf ( "Output = %d\n", value );
    func();

}

Question Number 247

Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/*  Test1.h */
static int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
void func()
{
    func1();
}

/* Test2.c */
#include "Test1.h"

void func1()
{
    printf ( "Output = %d\n", ++value );

}


/* Test3.c */

#include "Test1.h"

void main ()
{
    func1();
    func();
}

Question Number 248

Give the output of the following code snippet who's solution configuration has been set to the DEBUG mode :
int main()
{
    int a = 200, b = 100, c = 2;
    _asm
    {
        mov eax, esp
        mov ebx, 10
        push eax
        push ebx
        mov ecx, esp
        mov ebx, dword ptr[b]
        sub ecx, eax
        mov a, ecx
        mov b, ebx
        pop ebx
        add esp,4

    }
    printf("%d %d", a, b);
}

Question Number 249

Give the output of the following code snippet :
void main()
{
    int ch=0,sum=0,i;
    int num=7;
    for (i=0; i< 4; i++)
    {
        printf("%d",(num << i & 1 <<  3)? 0 : 1);
    }
}

Question Number 250

Give the output of the following code snippet :
int f(int i)
{
    int sum=0;
    _asm
    {
        mov         dword ptr [sum],14h
        mov         eax,dword ptr [i]
        add         eax,0Ah
        mov         dword ptr [i],eax
        imul        ecx,dword ptr [sum],0Ah
        mov         dword ptr [sum],ecx
        mov         eax,dword ptr [i]
    }
}

void main()
{
    int a;
    int(*fptr)(int) = f;
    _asm
    {
        push        64h
        call        dword ptr [fptr]
        add         esp,4
        mov         dword ptr [a],eax
    }
    printf("%d", a);
}

Question Number 251

Give the output of the following code snippet :
struct student
{
    char *name;
};
void main()
{
    struct student s[2];
    s[1] = s[0] = "Jenn";
    printf("%s %s", s[0].name, s[1].name);
}

Question Number 252

Give the output of the following code snippet :
typedef struct stud s;
void func(struct stud *stuobj);
struct stud
{
    int no;
    int no2;
    s *link;
};

void main()
{
    struct stud s= {10,20};
    func(&s);
}
void func(struct stud *stuobj)
{
    struct stud *s;
    s=stuobj;
    printf("%d",s->no);
}

Question Number 253

Give the output of the following code snippet :
typedef struct stud
{
    int no;
    int no2;
    stud *link;
} stud;
void main()
{
    stud s;
    s.no=10;
    printf("%d",s.no);
}

Question Number 254

Give the output of the following code snippet :
struct node
{
    int data;
    struct node *next;
}*head;

void add( int num )
{
    struct node *temp;
    temp=(struct node *)malloc(sizeof(struct node));
    temp->data=num;
    if (head== NULL)
    {
        head=temp;
        head->next=NULL;
    }
    else
    {
        temp->next=head;
        head=temp;
    }
}

void  display()
{
    struct node *r;
    r=head;
    while(r!=NULL)
    {
        printf("%d ",r->data);
    }
}

void main()
{
    add(100);
    add(200);
    add(300);
    add(400);
    display();
}

Question Number 255

Give the output of the following code snippet :
int mul(int a, int b)
{
    return a * b;
}
void main()
{
    int (*fptr)();
    fptr = mul;
    printf("%d",fptr(2, 3));
}