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 :
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 Delete(int num)
{
    struct node *temp;
    temp=head;
    while(temp!=NULL)
    {
        if(temp->data==num)
        {
            if(temp==head)
            {
                head=head->next;
                head->prev=NULL;
            }
            else
            {
                if(temp->next==NULL)
                    temp->prev->next=NULL;
                else
                {
                    temp->next->prev=temp->prev;
                    temp->prev->next=temp->next;

                }
            }
            free(temp);
            return;
        }
        temp= temp->next;
    }
}



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

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

Question Number 2

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

Question Number 3

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;
            printf("%d ",arr[i][j]);
        }
    }
    free(arr);
    printf("%d",sizeof(arr));
}

Question Number 4

Give the output of the following code snippet :
int main()
{
    const char *s;
    char str[] = "SourceLens";
    s = str;
    printf("%s", s);
}

Question Number 5

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]);
    return 0;
}

Question Number 6

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

Question Number 7

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

Question Number 8

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

Question Number 9

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

Question Number 10

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

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

Question Number 11

Give the output of the following code snippet :
int f(int i)
{
    _asm
    {
        mov         eax,dword ptr [i]
        add         eax,6Ah
        add		  eax,0Fh
        mov         ebx,2Ch
        and		  eax,ebx
        xor		  eax,ebx
        mov         dword ptr [i],eax
        mov         eax,dword ptr [i]
    }
}

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

Question Number 12

Give the output of the following code snippet :
void main()
{
    int a=100,c=0,b=0;
    _asm
    {
        mov eax,-15
        mov ebx,a
        sub eax,ebx
        mov b,eax
        add eax,a
        jns Label1
        mov c,ebx
    }
Label1: printf("%d %d",b,c);
}

Question Number 13

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

Question Number 14

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;
    for(i=0; i< num; i++)
    {
        j=va_arg(marker,int);
        printf("%d ",j);
    }
    va_end(marker);
}
int main(int argc, char *argv[])
{
    disp(4,10,20,30);
}

Question Number 15

Give the output of the following code snippet :
struct student
{
    char *name;
};
void func(struct student *s)
{
    strcpy(s.name,"Jenn");
    printf("%s\t", s.name);
}
void main()
{
    struct student *s;
    func(s);
}

Question Number 16

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

Question Number 17

Give the output of the following code snippet :
int main()
{
    float x = 0.3;
    int y=10;
    if (x == 0.3f)
        printf("%f",2*3+6/3.0);
    else
        printf("%f",2*3+6*3.0);
}

Question Number 18

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);
    for(i=0; i< num; i++)
    {
        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 19

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

Question Number 20

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

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

Question Number 21

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

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

}

Question Number 22

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

Question Number 23

Give the output of the following code snippet :
void main()
{
    char str1[15]="Hello World";
    char *str="Yellow";
    str1[5]='\0';
    printf("%s",str1);
}

Question Number 24

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

Question Number 25

Give the output of the following code snippet :
int main()
{
    struct u
    {
        unsigned char x : 1;
        unsigned int y : 35;
    } p;
    struct u un;
    un.y = 100;
    printf("%d\n", un.y);
}

Question Number 26

Give the output of the following code snippet :
typedef struct stud
{
    int no;
    int no2;
    studobj *link;
} studobj;

void main()
{
    studobj s=(studobj *)malloc(sizeof(struct studobj));
    s->no=10;
    printf("%d",s->no);
}

Question Number 27

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 eax
        pop ebx
        mov a,eax
        mov b,ebx
    }
    printf("%d %d",a,b);
}

Question Number 28

Give the output of the following code snippet :
struct point
{
    int x;
    int y;
    int z;

};
int main()
{
    int* offset=&(((point*)0).z);
    printf("%d",offset);
}

Question Number 29

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

Question Number 30

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

}

Question Number 31

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

Question Number 32

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

Question Number 33

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

Question Number 34

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);
    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 35

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 36

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]
        xor edx,ecx
        mov c,eax
        sub edx,ecx
        add edx,10
        mov d,edx
        ret
    }
Label2:
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 37

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

Question Number 38

Give the output of the following code snippet :
#define valx 2
#define valy 2
#define valz 2
void main()
{
    int ***arr;
    int i,j,k;
    arr=(int***)malloc(valx*sizeof(int**));
    for(i=0; i< valx; i++)
    {
        arr[i]=(int*)malloc(valy*sizeof(int*));
        for(j=0; j< valy; j++)
            arr[i][j]=(int*)malloc(valz*sizeof(int));
    }
    for(k=0; k< valz; k++)
    {
        for(i=0; i< valx; i++)
        {
            for(j=0; j< valy; j++)
            {
                arr[i][j][k]=i+j+k;
                printf("%d ",arr[i][j][k]);
                break;
            }
        }
    }
}

Question Number 39

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][3] = {0};
    f(a);
}

Question Number 40

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

}

Question Number 41

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 42

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,res);
}

Question Number 43

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
        push 30
        push 40
        mov ebx,30
        mov eax, 40
        mov ecx,label1
        call ecx
        add esp, 8
        mov edx,Label2
        mov dword ptr[c],edx
        jmp dword ptr[c]
        label1:
        mov eax, dword ptr[esp + 4]
        mov a, eax
        mov eax, dword ptr[esp + 8]
        mov b, eax
        mov eax, dword ptr[esp + 12]
        mov c,ebx
        ret

        Label2:mov c,ebx
        mov b,200
    }
    printf("%d %d %d", a, b, c);

}

Question Number 44

Give the output of the following code snippet :
int main()
{
    float x=0.3,y=10.89,z=20.68;
    if( x == 0.3)
        printf("%.0f",fmod(z,y));
    else
        printf("%.0f",fmod(y,z));
}

Question Number 45

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

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;
}
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->next;
    while(r->next!=NULL)
    {
        printf("%d ",r->x);
        r=r->next;
    }
    printf("\n");
}

int main()
{
    AddNode(10);
    AddNode(5);
    AddNode(6);
    AddNode(100);
    AddNode(200);
    ReverseList();
    Display();
}

Question Number 46

Give the output of the following code snippet :
void convertToBinary(int val)
{
    for (int c = 7; c >= 0; c--)
    {
        int k = val >> c;

        if (k & 1)
            printf("1");
        else
            printf("0");
    }
}
int main()
{
    convertToBinary(20);

}

Question Number 47

Give the output of the following code snippet :
int DecimalToOctal(long quotient)
{
    long remainder;
    int octalNumber[100], i = 1, j;
    while (quotient != 0)
    {
        octalNumber[i++] = quotient % 8;
        quotient = quotient / 8;
    }
    for (j = i - 1; j > 0; j--)
        printf("%d", octalNumber[j]);
    return 0;
}
void main()
{
    DecimalToOctal(800);
}

Question Number 48

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 49

Give the output of the following code snippet :
int sum(int x,int y)
{
    return x+y;
}
void main()
{
    int (*fptr)(int a,int b);
    fptr = sum;
    printf("%d",(*fptr)(10,20));
}

Question Number 50

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 51

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 200;
    __asm
    {

        cmp dword ptr[ebp - 4], 0C8h
        jne Label1
        mov dword ptr[ebp - 4], 64h
        jmp Label2
        Label1 : mov dword ptr[ebp - 4], 12Ch
    }
Label2:

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

Question Number 52

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

Question Number 53

Give the output of the following code snippet whose solution configuration has been set to the DEBUG mode :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    __asm
    {
        push 100
        push 200
        push 300
        call Func
        jmp End
        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, 0xC
    }
    printf("%d %d %d", a, b, c);
}

Question Number 54

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    __asm
    {
        push 100
        push 200
        call Func
        jmp End
        Func :
        pop dword ptr[esp]
        mov eax, dword ptr[esp]
        mov a, eax
        pop dword ptr[esp+8]
        mov eax, dword ptr[esp + 8]

        mov a, eax
        ret
        End :
    }
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 55

Give the output of the following code snippet :
int main()
{
    char *p = NULL;
    char *q = 0;
    if (!p)
        printf("P ");
    else
        printf("Nullp");
    if (!q)
        printf("Q ");
    else
        printf(" Nullq");
}

Question Number 56

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 57

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 ()
{
    func1(arg);
}

Question Number 58

Give the output of the following code snippet : Assume the input given is 100.
void main()
{
    int i=3;
    int x;
    while(i!=0)
    {
        scanf("%d",&x);
        printf("%d ",x);
        ungetc(x,stdin);
    }
}

Question Number 59

Give the output of the following code snippet :
void main()
{
    int i = 10, a = 10;
    _asm
    {
        mov         eax, dword ptr[i]
        and         eax, 80000001h
        jns         Label1
        dec         eax
        or          eax, 0FFFFFFFEh
        inc         eax
        Label1 : test        eax, eax
        jne         Label2
        jmp         Label3
        jmp         Label3
        Label2 : mov         dword ptr[a], 0C8h

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

Question Number 60

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

Question Number 61

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

Question Number 62

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 63

Give the output of the following code snippet with the following command line arguments : >Test.c 100 200 300
void func(char *arry[])
{
    for(int i=1; i< 3; i++)
        printf("%s ", (arry[i]));
}

int main(int argc, char *argv[])
{
    func(argv);
    return 0;
}

Question Number 64

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

Question Number 65

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= {1001,"Jenny"};
    func(&s);
}
void func(struct stud *stuobj)
{
    struct stud *s;
    s=stuobj;
    printf("%s",s->name);
}

Question Number 66

Give the output of the following code snippet :
union stud
{
    int age;
    int id;
};
void main()
{
    union stud s= {20};
    union stud *temp=(stud*)malloc(sizeof(stud));
    temp=&s;
    temp->age=30;
    printf("%d",temp->id);
}

Question Number 67

Give the output of the following code snippet :
void main()
{
    const int val=20;
    int arry[val];
    char str[val];
    arry[10]=10;
    arry[5]=20;
    str[3]='B';
    printf("%d %c",arry[10],++str[3]);
}

Question Number 68

Give the output of the following code snippet :
int main()
{
    int x=10,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 69

Give the output of the following code snippet :
void main()
{
    FILE *fp,*fp1;
    char x;
    fp = fopen("Test.txt","w+");
    fputs("Hello World", fp);
    fseek( fp, 10, SEEK_SET );
    fputs("Yello", fp);
    fclose(fp);
    fp1 = fopen("Test.txt","r");
    while(1)
    {
        x = fgetc(fp);
        if( feof(fp) )
        {
            break;
        }
        printf("%c", x);
    }
    fclose(fp1);

}

Question Number 70

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

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

Question Number 71

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

Question Number 72

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;
    const int *qtr=func(a);
    printf("%d",*qtr);
}

Question Number 73

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

Question Number 74

Consider the following snippet : Give the importance of the following lines : temp->next=temp2->next; temp2->next=temp;
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;
}

Question Number 75

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    __asm
    {
        push 10
        push 20
        push 30
        push 40
        call Func
        jmp End
        Func :
        add esp, 4
        pop eax
        mov a, eax
        pop eax
        mov b, eax
        pop eax
        mov c, eax
        add eax,c
        or eax,b
        xor eax,a
        mov d,eax
        sub esp, 0x10
        ret
        End : add esp, 0x10
    }
    printf("%d %d %d %d", a, b, c, d);
}

Question Number 76

Give the output of the following code snippet :
void main()
{
    typedef char ptr,*qtr;
    char fptr=100;
    qtr a,b;
    ptr p=20,q=30;
    a=&fptr;
    b=&p;
    printf("%d %d",*a,*b);
}

Question Number 77

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",**p+3,*q+5);

}

Question Number 78

Give the output of the following code snippet :
int main()
{
    int a = 0;
    int b = 0;
    int c = 0;
    _asm
    {
        mov eax, 10
        push eax
        mov ebx, 100
        push ebx
        mov ecx, 1000
        push ecx
        push 100
        mov ebx, dword ptr[esp]
        mov a, ebx
        mov ebx, dword ptr[esp+4]
        mov b, ebx
        mov ebx, dword ptr[esp-8]
        mov c, ebx
        add esp, 0x10
    }
    printf( "%d %d %d", a, b, c );
}

Question Number 79

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

        mov         ecx, dword ptr[i]
        imul        ecx, dword ptr[j]
        add         ecx, dword ptr[sum]
        mov         dword ptr[sum], ecx

        jmp         Label3

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

Question Number 80

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 81

Give the output of the following code snippet :
struct point
{
    int x;
    int y;
};
struct point func(struct point);
int main()
{
    struct point p1 = {1, 2};
    p1.y=func(p1);
    printf("%d\n", p1.y);
}
struct point func(struct point p)
{
    p.y=20;
    return p;
}

Question Number 82

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

Question Number 83

Give the output of the following code snippet :
struct student
{
    char c[10];
    int age;
};
void main()
{
    struct student s= {"Jenn",15};
    struct student m;
    m=s;
    if(m==s)
        printf("%s",m.c);
    else
        printf("%s",strupr(m.c));
}

Question Number 84

Give the output of the following code snippet :
void main()
{
    int a = 5;
    _asm
    {
        mov         dword ptr[ebp - 0D0h], 5
        cmp         dword ptr[ebp - 0D0h], 1
        je          Label1
        cmp         dword ptr[ebp - 0D0h], 5
        je          Label2
        jmp         Label3
        Label1 : mov         dword ptr[a], 0Ah
        jmp         Label3
        Label2 : mov         dword ptr[a], 14h

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

Question Number 85

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

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

Question Number 86

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 87

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

Question Number 88

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]
        mov ecx,10
        and ecx,ebx
        inc 10
        mov dword ptr[c],ecx

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

Question Number 89

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 90

Give the output of the following code snippet :
int main()
{
    int i, *p;
    _asm
    {
        mov         dword ptr[i], 0Ah
        lea         eax, [i]
        mov         dword ptr[p], eax
        mov         ecx, dword ptr[p]
        mov         edx, dword ptr[p]
        mov         eax, dword ptr[edx]
        mov         dword ptr[ecx], eax
        mov         ecx, dword ptr[p]
        mov         edx, dword ptr[ecx]
        add         edx, 1
        mov         eax, dword ptr[p]
        mov         dword ptr[eax], edx

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

Question Number 91

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

Question Number 92

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

    int a = 10,b=20,c=0;
    _asm
    {
        cmp         dword ptr[a], 0Ah
        je          Label1
        cmp         dword ptr[a], 14h
        jne         Label2
        Label1:   mov         eax, dword ptr[a]
        add         eax, dword ptr[b]
        mov         dword ptr[c], eax
        jmp         Label3
        Label2:    mov         eax, dword ptr[a]
        sub         eax, dword ptr[b]
        mov         dword ptr[c], eax
    }
Label3 :
    printf("%d", c);

}

Question Number 93

Give the importance of the following lines of code from the given function : 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 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;
    }

}

Question Number 94

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 */

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

}

/* Test2.c */

#include"Test1.h"

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

}

Question Number 95

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

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

Question Number 96

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         eax, dword ptr[i]
        add        eax, dword ptr[ecx]
        mov         ecx, dword ptr[j]
        cdq
        imul        dword ptr[ecx]
        sub        eax, dword ptr[i]
        mov         dword ptr[k], eax
    }
    printf("%d\n", k);
    return 0;
}

Question Number 97

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

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

Question Number 98

Give the output of the following code snippet :
void main()
{
    int x = 100, y = 200, min;
    _asm
    {
        mov         eax, dword ptr[x]
        cmp         eax, dword ptr[y]
        jge         Label1

        mov         eax, dword ptr[x]
        mov         dword ptr[min], eax

        jmp         Label2

        Label1 : mov         eax, dword ptr[y]
        mov         dword ptr[min], eax


    }
Label2:	printf("%d", min);
}

Question Number 99

Give the output of the following code snippet :
#define valx 2
#define valy 2
#define valz 2
void main()
{
    int ***arr;
    int i,j,k;
    arr=(int***)malloc(valx*sizeof(int**));
    for(i=0; i< valx; i++)
    {
        arr[i]=(int**)malloc(valy*sizeof(int*));
        for(j=0; j< valy; j++)
            arr[i][j]=(int*)malloc(valz*sizeof(int));
    }
    for(k=0; k< valz; k++)
    {
        for(i=0; i< valx; i++)
        {
            for(j=0; j< valy; j++)
            {
                arr[i][j][k]=i*j*k;
                printf("%d ",arr[i][j][k]);
                break;
            }
        }
    }
}

Question Number 100

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

Question Number 101

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

Question Number 102

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 103

Give the output of the following code snippet :
int main()
{
    int i, *j, k;
    _asm
    {
        mov         dword ptr[i], 5
        lea         eax, [i]
        mov         dword ptr[j], eax
        mov         ecx, dword ptr[j]
        mov         edx, dword ptr[ecx]
        sub         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]
        add         edx, dword ptr[eax]
        mov         dword ptr[k], edx
    }
    printf("%d\n", k);
}

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 func1();

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

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

void func1()
{
    value  = 200;
    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 :
int main()
{
    int a = 20, b = 10,c=2;
    _asm
    {
        mov eax,esp
        mov ebx,100
        push dword ptr[a]
        push dword ptr[b]
        mov ecx,esp
        pop dword ptr[b]
        sub ecx,eax
        mov a,eax
        mov b,ebx
        mov c,ecx
        pop dword ptr[b]
    }
    printf("%d %d  %d",a,b,c);
}

Question Number 106

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

Question Number 107

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

Question Number 108

Give the output of the following code snippet :
int main()
{
    char str1[15] = "Hello";
    char *str;
    str=str1;
    while(*str!='\0')
    {
        *str=*str+2;
        str++;
    }
    printf("%s",str1);
    return 0;
}

Question Number 109

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]
        mov ecx,c
        and ecx,ebx
        inc ecx
        mov dword ptr[c],ecx

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

Question Number 110

Give the output of the following code snippet :
void main()
{
    int i = 13, a = 10;
    _asm
    {
        mov         eax, dword ptr[i]
        and         eax, 80000001h
        jns         Label1
        dec         eax
        or          eax, 0FFFFFFFEh
        inc         eax
        Label1 : test        eax, eax
        jne         Label2
        jmp         Label5
        jmp         Label5
        jmp         Label3
        Label2 : mov         dword ptr[a], 0C8h
        Label3 : jmp         Label4
        jmp         Label4
        Label5 : mov         dword ptr[a], 190h

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

Question Number 111

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"
int value = 300;
void func()
{
    value=200;
    printf ( "Output = %d\n", ++value );
    func1();

}

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

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

}


/* Test3.c */

#include "Test1.h"

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

Question Number 112

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

    _asm
    {
        mov         dword ptr[a], 0Ah
        mov         dword ptr[b], 14h
        lea         eax, [a]
        mov         dword ptr[Pa1], eax
        lea         ecx, [b]
        mov         dword ptr[Pa2], ecx
        mov         edx, dword ptr[Pa1]
        mov         ecx, dword ptr[Pa2]
        mov         eax, dword ptr[edx]
        cdq
        idiv        dword ptr[ecx]
        mov         dword ptr[c], eax
        lea         edx, [c]
        mov         dword ptr[Pa3], edx
    }

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

Question Number 113

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  displayrev()
{
    struct node *r;
    r=head;
    while(r->next!=NULL)
        r=r->next;
    while(r!=NULL)
    {
        printf("%d ",r->data);
        r=r->prev;
    }
    printf("\n");
}

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

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

Question Number 114

Give the output of the following code snippet :
void main()
{
    int k, sum = 0, prod = 0;
    _asm
    {
        mov         dword ptr[k], 0FFFFFFFDh
        jmp         Label1
        Label3 : 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[sum]

        add         ecx, dword ptr[k]
        mov         dword ptr[sum], ecx

        mov         edx, dword ptr[k]
        imul        edx, dword ptr[sum]
        mov         dword ptr[prod], edx

        jmp         Label3


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

Question Number 115

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

Question Number 116

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

Question Number 117

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 118

Give the output of the following code snippet :
void main()
{
    typedef long int a;
    a c,d;
    c=10;
    d=100;
    printf("%d %d",c,d);
}

Question Number 119

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

        Label1 : mov         dword ptr[a], 0Ah

        jmp         Label3

        Label2 : mov         dword ptr[a], 64h

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

Question Number 120

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

Question Number 121

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

Question Number 122

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

Question Number 123

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;
void func();

/* Test1.c */

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

}

/* Test2.c */

#include"Test1.c"
void main ()
{
    printf ( "Output = %d\n", value );
    func();

}

Question Number 124

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

Question Number 125

Give the output of the following code snippet :
struct p
{
    int x;
};
int main()
{
    struct p p1[] = {1, 92, 3, 94, 5, 96};
    struct p *ptr1 = p1;
    int x = (sizeof(p1) / sizeof(ptr1));
    if (x == 1)
        printf("%d\n", ptr1->x);
    else
        printf("%d",x);
}

Question Number 126

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

Question Number 127

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 128

Consider the following snippet : Give the importance of the following lines : for(int i=1;i<=n;i++) { temp2=temp2->next; }
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;
}

Question Number 129

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

    int c = a ^ b;
    int d = ~b + 1;

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

}

Question Number 130

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

Question Number 131

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

Question Number 132

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

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 :
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(10,2.2,3.3,4.4);
}

Question Number 135

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

Question Number 136

Give the output of the following code snippet :
int main()
{
    union u
    {
        unsigned int x : 1;
        unsigned int y : 4;
    } p;
    union u *un=(u*)malloc(sizeof(u));
    un->y = 2;
    printf("%d\n",sizeof(un));
}

Question Number 137

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[])
{
    int i=strlen(argv[3]);
    int sum=0;
    do
        printf("%d ",atoi(argv[--argc])-atoi(argv[argc])-atoi(argv[--argc]));
    while(!argc);
}

Question Number 138

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    __asm
    {
        push 20
        push 30
        push 40
        call Func
        jmp End
        Func :
        add esp, 4
        pop eax
        mov a, eax
        pop eax
        mov b, eax
        pop eax
        mov c, eax
        and eax,b
        shl eax,2
        mov d,eax
        sub esp, 0x10
        ret
        End : add esp, 0xC
    }
    printf("%d %d %d %d", a, b, c, d);
}

Question Number 139

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[])
{
    printf("%s\n", *argv);
    return 0;
}

Question Number 140

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

void add( char* 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("%s ",r->data);
        r=r->next;
    }
}

void main()
{
    struct node *n;
    add("Hello");
    add("World");
    display(n);
}

Question Number 141

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
        push 200
        push 300
        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 142

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 143

Give the output of the following code snippet :
int main()
{
    int a,b=2,c=10;
    _asm
    {
        mov dword ptr[a],0
        mov ecx,dword ptr[b]
        mov dword ptr[b],20
        add ecx,dword ptr[c]
        shl ecx,2
        dec ecx
        mov a,ecx
    }
    printf("%d",a);
}

Question Number 144

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

{
    int sum=0;
    _asm
    {
        mov         dword ptr [a],0Ch
        mov         eax,dword ptr [sum]
        add         eax,dword ptr [a]
        mov         dword ptr [sum],eax
        mov         ecx,dword ptr [a]
        add         ecx,1
        mov         dword ptr [a],ecx
    }
    printf("%d",a);
    return 0;
}
int testCaller(int(*funcptr) (int a))
{
    _asm
    {
        push        10h
        call        dword ptr [funcptr]
        add         esp,4
    }
    return 0;
}

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

Question Number 145

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

Question Number 146

Consider the following code: Where are the elements added to in the list?
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 main()
{
    func(100);
    func(200);
    func(300);
    func(400);
    display();
}

Question Number 147

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 */

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

}

/* Test2.c */

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

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

Question Number 148

Give the output of the following code snippet :
void main()
{
    int k=0,z;
    printf("%d == 1" "%d " ,k,k==1?z=k++:z=--k);

}

Question Number 149

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[])
{
    int i=strlen(argv[3]);
    int sum=0;
    do
        printf("%d ",atoi(argv[argc])+atoi(argv[--argc])+atoi(argv[argc]));
    while(argc);
}

Question Number 150

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

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

Question Number 151

Give the output of the following code snippet :
#include< stdio.h>
int main()
{
#define VAR 10
    typedef int iptr;
    static iptr *ptr,*qtr;
    int *rptr;
    int x=VAR;
    int y=200;
    ptr=&x;
    qtr=&y;
    printf("%d",(*ptr)+(*qtr));
}

Question Number 152

Give the output of the following code snippet :
struct stud
{
    int no;
    int no2;
    struct emp *link;
};
struct emp
{
    int id;
    struct emp *link2;
};
typedef struct stud *ptr;
typedef struct emp *qtr;

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

Question Number 153

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

Question Number 154

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 155

Give the output of the following code snippet with the following command line arguments : >Test.c Hello World Program
int main(int argc, char *argv[])
{
    int i=strlen(argv[3]);
    int sum=0;
    while(argc)
        printf("%s ",argv[argc]);
}

Question Number 156

Give the output of the following code snippet :
int sum(int x, int y)
{
    _asm
    {
        mov         eax,dword ptr [x]
        add         eax,dword ptr [y]
    }
}
void main()
{
    int(*fptr)(int a, int b);
    int a = 0;
    fptr=sum;
    _asm
    {
        push        14h
        push        0Ah
        call        dword ptr [fptr]
        add         esp,8
        mov         dword ptr [a],eax
    }
    printf("%d", a);
}

Question Number 157

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

Question Number 158

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
        pop ebx
        sub ecx,eax
        mov a,ecx
        mov b,ebx

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

Question Number 159

Give the output of the following code snippet :
int main()
{
    int c=10;
    _asm
    {
        mov eax,10
        mul dword ptr[c],20
        mov c, eax
    }
    printf("%d", c);
}

Question Number 160

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 161

What is the output of the following code snippet if it is run with no commandline arguments?
int main(int argc, char *argv[])
{
    printf("%d\n", argc);
    return 0;
}

Question Number 162

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 163

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[5];
    Vobj[0].Cobj.Id=1001;
    printf("%d",Vobj[1].Cobj.Id);
}

Question Number 164

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

        mov         ecx, dword ptr[i]
        imul        ecx, dword ptr[i]
        add         ecx, dword ptr[sum]
        mov         dword ptr[sum], ecx

        jmp         Label3

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

Question Number 165

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

Question Number 166

Give the output of the following code snippet :
int main()
{
    int a = 10, b = 20, c;
    _asm
    {
        mov eax, a
        mul c
        mov c, eax
    }
    printf("%d %d", a, c);
}

Question Number 167

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

}

Question Number 168

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

Question Number 169

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);
    for(i=0; i< num; i++)
    {
        j=va_arg(marker,int);
        k=va_arg(marker,char);
        printf("%d %c ",j,k);
    }
    va_end(marker);
    return sum;
}
int main(int argc, char *argv[])
{
    print(3,96,97,98);
}

Question Number 170

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

Question Number 171

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]
        dec ebx
        mov ecx,c
        or  ecx,ebx
        mov dword ptr[c],ecx
    }
    printf("%d",c);
}

Question Number 172

What type of initialization is needed for the segment "ptr[3] = ’3′;" to work?
< NIL>

Question Number 173

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

Question Number 174

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

Question Number 175

What do the following line of code in the function indicate? temp->prev->next=NULL;
void Delete(int num)
{
    struct node *temp;
    temp=head;
    while(temp!=NULL)
    {
        if(temp->data==num)
        {
            if(temp==head)
            {
                head=head->next;
                head->prev=NULL;
            }
            else
            {
                if(temp->next==NULL)
                    temp->prev->next=NULL;
                else
                {
                    temp->next->prev=temp->prev;
                    temp->prev->next=temp->next;

                }
            }
            free(temp);
            return;
        }
        temp= temp->next;
    }
}

Question Number 176

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

Question Number 177

Give the output of the following code snippet :
void main()
{
    int x = 5, y = 2, z = 3;
    int a = x & y | z;
    printf("%d", a);
}

Question Number 178

Give the output of the following code snippet :
struct point
{
    int x;
    int y;
};
int main()
{
    struct point p = {1};
    struct point p1 = {1,1};
    if(p.y == p1.y)
        printf("Equal\n");
    else
        printf("Not equal\n");
}

Question Number 179

Give the output of the following code snippet :
#define VAR 10
void func()
{
    printf("%d ",VAR);
}
int main()
{
    typedef int iptr;
    static iptr *ptr,*qtr;
    int *rptr;
    int x=VAR;
    int y=200;
    ptr=&x;
    qtr=&y;
    printf("%d  ",(*ptr)+(*qtr));
    func();
}

Question Number 180

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 181

Give the output of the following code snippet :
int main()
{
    int a = 10, b = 20, c;
    _asm
    {
        mov eax, a
        mul b
        mov c, eax
    }
    printf("%d", c);
}

Question Number 182

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

Question Number 183

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

{
    int i = 3, a = 10, j = 5;
    _asm
    {
        Label3:   cmp         dword ptr[i], 5
        je          Label1
        mov         eax, dword ptr[i]
        add         eax, 1
        mov         dword ptr[i], eax
        cmp         dword ptr[i], 3
        je          Label2
        jmp         Label3
        jmp         Label4
        Label2 : mov         ecx, dword ptr[a]
        add         ecx, 1
        mov         dword ptr[a], ecx
        Label4 : jmp         Label3

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

Question Number 184

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

Question Number 185

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 186

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

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

Question Number 187

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 188

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

Question Number 189

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 190

Give the output of the following code snippet :
int main()
{
    float x=10.00;
    float y=10.001;
    if( x == y)
        printf("%.0f",x++ + ++y);
    else
        printf("%.0f",--y-++x);
}

Question Number 191

Give the output of the following code snippet :
void main()
{
    int a=20,c=0,b=0;
    _asm
    {
        mov eax,-30
        mov ebx,a
        cmp eax,ebx
        je Label2
        mov b,eax
        Label2:
        mov c,ebx

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

Question Number 192

Give the output of the following code snippet :
int i=100;
void func(int i)
{
    printf("%d ",i);
}
void func2(int i)
{
    printf("%d ",i);
}
void func3()
{
    printf("%d ",i);
}
void main()
{
    int x=10;
    func(x);
    func2(x);
    func3();
}

Question Number 193

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]+3);
    return 0;
}

Question Number 194

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 eax
        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 195

Give the output of the following code snippet :
int mult(int x, int y)
{
    _asm
    {
        mov         eax,dword ptr [x]
        mul         dword ptr [y]
    }
}
void main()
{
    int(*fptr)(int a, int b);
    int a = 0;
    fptr=mult;
    _asm
    {
        push        64h
        push        4h
        call        dword ptr [fptr]
        add         esp,8
        mov         dword ptr [a],eax
    }
    printf("%d", a);
}

Question Number 196

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",ptr1->y);
}

Question Number 197

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

    printf("%d", a);
}

Question Number 198

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

int main(int argc, char **argv)
{
    printf("%s\n", argv[argc-1]);
    return 0;
}

Question Number 199

The & operator cannot be used to applied to which of the following?
< NIL>

Question Number 200

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

Question Number 201

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

Question Number 202

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

Question Number 203

Give the output of the following code snippet :
void func(char *s)
{
    char *ptr;
    ptr=s;
    printf("%s",ptr);
}
void main()
{
    char *str=(char*)malloc(sizeof(char));
    func(str);
}

Question Number 204

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

Question Number 205

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[])
{
    int i;
    for(i=1; i< argc; i++)
        printf("%s ", *(argv+1));
    return 0;
}

Question Number 206

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

Question Number 207

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 208

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->next!=NULL)
    {
        printf("%d ",r->data);
        r=r->next;
    }
}

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

Question Number 209

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

Question Number 210

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

        Label1 : mov         dword ptr[a], 0Ah

        jmp         Label4

        Label2 : mov         dword ptr[a], 32h

        jmp         Label4

        Label3 : mov         dword ptr[a], 64h

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

Question Number 211

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

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

Question Number 212

Give the output of the following code snippet :
void main()
{
    int x=0,z;
    float p=2.4567;
    double q=5.6543;
    float r=0.0;
    printf("%.2f %.4lf",p+q-r,q);
}

Question Number 213

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 50
        push 40
        mov ebx,30
        mov eax, 40
        mov ecx,60
        call label1
        add eax,ebx
        mov a,eax
        mov c,edx
        add esp, 16
        jmp Label2
        label1:
        mov eax, dword ptr[esp + 4]
        mov a, eax
        add a, ebx
        mov eax, dword ptr[esp + 12]
        mov b, eax
        mov eax, dword ptr[esp + 20]
        xor edx,ecx
        mov c,eax
        and edx,ecx
        mov d,ebx
        ret
    }
Label2:
    printf("%d %d %d %d", a, b, c, d);

}

Question Number 214

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"
int value = 300;
void func()
{
    value=200;
    printf ( "Output = %d\n", ++value );
    func1();

}

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

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

}


/* Test3.c */

#include "Test1.h"

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

Question Number 215

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

    int c=-(~(~a)+1);
    printf("%d",c);

}

Question Number 216

Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
    int a = 100;
    __asm
    {

        cmp dword ptr[ebp - 4], 0C8h
        jne Label1
        mov dword ptr[ebp - 4], 64h
        jmp Label2
        Label1 : mov dword ptr[ebp - 4], 12Ch
    }
Label2:

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

Question Number 217

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

Question Number 218

Consider the given code given below : Give the importance of the nodes temp4 and 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 219

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

Question Number 220

Give the output of the following code snippet:
void main()
{
    char *s = "hello";
    char *p = s[3];
    printf("%c\t%c", *p, s[1]);
}

Question Number 221

Give the output of the following code snippet :
void main()
{
    int x, *ptr1, y;
    _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
        mov         edx, dword ptr[ptr1]
        mov         eax, dword ptr[edx]
        add         eax, dword ptr[x]
        mov         dword ptr[y], eax
        mov         ecx, dword ptr[ptr1]
        add         ecx, 4
        mov         dword ptr[ptr1], ecx
    }
    printf("%d ", y);
}

Question Number 222

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

Question Number 223

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

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;
}
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;
    while(r!=NULL)
    {
        printf("%d ",r->x);
        r=r->next;
    }
    printf("\n");
}

int main()
{
    AddNode(10);
    AddNode(5);
    AddNode(6);
    AddNode(100);
    AddNode(200);
    Display();
    ReverseList();
    Display();
}

Question Number 224

Give the output of the following code snippet :
void func(int i)
{
    printf("%d ",i);
}
void func2(int i)
{
    printf("%d ",i);
}
void func3()
{
    printf("%d ",i);
}
void main()
{
    int x=10;
    func(x);
    func2(x);
    func3();
}

Question Number 225

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

int main(int argc, char *argv[])
{
    func(argv);
    return 0;
}

Question Number 226

Give the output of the following code snippet :
union stud
{
    int age;
    char *name;
};
void main()
{
    union stud s= {20};
    union stud *temp=(stud*)malloc(sizeof(stud));
    temp=&s;
    printf("%d",temp->age);
}

Question Number 227

Give the output of the following code snippet :
struct point
{
    int x;
    int y;
};
int main()
{
    struct point p = {1};
    struct point p1 = {1};
    if(p.x == p1.x)
        printf("Equal\n");
    else
        printf("not equal\n");
}

Question Number 228

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  displayrev()
{
    struct node *r;
    r=head;
    while(r->next!=NULL)
        r=r->next;
    while(r!=NULL)
    {
        printf("%d ",r->data);
        r=r->prev;
    }
    printf("\n");
}

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

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

Question Number 229

Give the output of the following code snippet :
void main()
{
    char *s = "SourceLens";
    char *p = s;
    printf("%c %c", *(p+1), s[10]);
}

Question Number 230

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(fp,"%s","Hello","World");
    fclose(fp);
}

Question Number 231

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

Question Number 232

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 233

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

Question Number 234

Give the output of the following code snippet who's solution configuration has been set to the DEBUG mode :
int main()
{
    int a = 0;
    int b = 0;
    int c = 0;
    _asm
    {
        mov eax, 10
        push eax
        mov ebx, dword ptr[esp]
        mov a, ebx
        mov ebx, dword ptr[esp + 4]
        mov b, ebx
        push 300
        mov ebx, dword ptr[esp + 8]
        mov c, ebx
        add esp,4
        pop eax
    }
    printf("%d %d %d", a, b, c);
}

Question Number 235

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",ptr1->x);
}

Question Number 236

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 237

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 238

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

Question Number 239

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

{
    int i = 3, a = 10, j = 5, sum = 0;
    _asm
    {
        Label3:   cmp         dword ptr[i], 0
        je          Label1
        mov         eax, dword ptr[a]
        add         eax, dword ptr[sum]
        mov         dword ptr[a], eax
        mov         ecx, dword ptr[i]
        sub         ecx, 1
        mov         dword ptr[i], ecx
        cmp         dword ptr[i], 2
        jne         Label2
        jmp         Label1
        Label2 : jmp         Label3

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

Question Number 240

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 */
extern int value;
void func();

/* Test1.c */

#include"Test2.h"

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

/* Test2.c */
#include"Test2.h"
int value = 200;

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

}



/* Test3.c */

#include "Test2.h"

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

Question Number 241

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

Question Number 242

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 243

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

Question Number 244

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

Question Number 245

Give the output of the following code snippet :
void main()
{
    char *str;
    char *str2;
    str="Hello";
    str2="World";
    str=str2;
    printf("%s",str);

}

Question Number 246

Give the output of the following code snippet :
void disp(int num,...);
int func();
void main()
{
    int (*ptr)();
    ptr=func;
    disp(100,ptr);
}
void disp(int num,...)
{
    int (*pfun)();
    int ptr;
    typedef int(*funcptr)();
    va_start(ptr,num);
    pfun=va_arg(ptr,funcptr);
    (*pfun)();
}
int func()
{
    printf("Hello World");
    return 0;
}

Question Number 247

Give the output of the following code snippet : Assume the contents of the file 'Test.txt' is "Hello World".
void main()
{
    char ch,x;
    FILE *fp,*fp1;
    char str[20];
    fp=fopen("Test.txt","rb");
    fp1=fopen("Destn.txt","w");
    while(1)
    {
        ch=getc(fp);
        if(ch==EOF)
            break;
        else
        {
            fputc(ch,fp1);
        }
    }
    fclose(fp);
    fclose(fp1);
    fp1=fopen("Destn.txt","r");
    while((x=getc(fp1))!=EOF)
        printf("%c",x);

}

Question Number 248

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

Question Number 249

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

Question Number 250

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("%c", *++argv[1] );
    return 0;
}

Question Number 251

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

Question Number 252

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

Question Number 253

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);
    func1(arg);

}

Question Number 254

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

int main(int argc, char **argv)
{
    printf("%s\n", *++argv+1);
    return 0;
}

Question Number 255

Give the output of the following code snippet :
void func3(int x);
int i=100;
void func(int i)
{
    printf("%d ",i++);
}
void func2(int i)
{
    printf("%d ",i++);
    func3(i);
}
void func3(int i)
{
    printf("%d ",i++);
}
void main()
{
    int x=10;
    func(x);
    func2(x);
}