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 :
int main()
{
    union a
    {
        int val;
        char ch[2];
    };
    union a unobj;
    unobj.ch[0]=10;
    printf("%d %d", unobj.ch[0]);
    return 0;
}

Question Number 2

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

Question Number 3

Give the output of the following code snippet :
void func(float *i)
{
    *i=200.5;
}

void func2(float i)
{
    i=300.75;
}
int main()
{
    float i=100.25;
    func(&i);
    func2(i);
    printf("%.2f ", i);
}

Question Number 4

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 5

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;
    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 6

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

int main()
{

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

Question Number 7

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

Question Number 8

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 u1 = {2};
    printf("%d\n", u1.p.x);
}

Question Number 9

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]
        sub         ecx, 0Ah
        add			ecx, dword ptr[x]
        mov         dword ptr[x], ecx
    }
    printf("%d ", *ptr1);
}

Question Number 10

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

Question Number 11

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

}

Question Number 12

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 = 400;
void func();
/* Test1.c */

#include "Test1.h"

static int value = 100;
void func()
{
    static int value = 200;
    printf ( "Output = %d\n", value );
    value = 300;

}

/* Test2.c */
static int value = 100;
void main ()
{
    func();
    printf ( "Output = %d\n", value );
}

Question Number 13

Give the output of the following code snippet :
int BinaryToOctal(long int binarynum)
{
    long int octalnum = 0, j = 1, remainder;
    while (binarynum != 0)
    {
        remainder = binarynum % 10;
        octalnum = octalnum + remainder * j;
        j = j * 2;
        binarynum = binarynum / 10;
    }
    printf("%lo", octalnum);
    return 0;
}

void main()
{
    BinaryToOctal(1000);
}

Question Number 14

Consider the given code given below : What do the nodes temp1 and temp3 point to? temp3=temp1=Head; temp2=temp1->next;
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 15

Give the output of the following code snippet :
typedef int val1;
#define INT float;
void main()
{
    val1 a=100,b=200;
    INT x=10,y=20;
    printf("%d %d",a+b,x+y);
}

Question Number 16

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

int count()
{
    struct node *n;
    int c=0;
    n=head;
    while(n!=NULL)
    {
        n=n->next;
        c++;
    }
    printf("%d",c);
    return 0;
}

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

}

int Delete(int num)
{
    struct node *temp, *prev;
    temp=head;
    while(temp!=NULL)
    {
        if(temp->data==num)
        {
            if(temp==head)
            {
                head=temp->next;
                free(temp);
                return 1;
            }
            else
            {
                prev->next=temp->next;
                free(temp);
                return 1;
            }
        }
        else
        {
            prev=temp;
            temp= temp->next;
        }
    }
    return 0;
}

void main()
{
    struct node *n;
    add(100);
    add(200);
    add(300);
    Delete(100);
    Delete(200);
    count();
}

Question Number 17

Give the importance of the following lines of code in the below function :
struct node
{
    int data;
    struct node *next;
}*head;

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

Question Number 18

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 19

Give the output of the following code snippet :
void BinaryToDecimal(int num)
{
    int binary_val, decimal_val = 0, base = 1, rem;
    while (num > 0)
    {
        rem = num % 10;
        decimal_val = decimal_val + rem * base;
        num = num / 10 ;
        base = base * 2;
    }
    printf("%d ", decimal_val);
}
void main()
{
    BinaryToDecimal(10001000);
}

Question Number 20

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=0;
    int sum=0;
    while(i!=argc)
    {
        printf("%s  ",*argv);
        i++;
    }
}

Question Number 21

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

Question Number 22

Predict the output of the following code snippet :

int Delete(int num)
{
    struct node *temp, *prev;
    temp=head;
    while(temp!=NULL)
    {
        if(temp->data==num)
        {
            if(temp==head)
            {
                head=temp->next;
                free(temp);
                return 1;
            }
            else
            {
                prev->next=temp->next;
                free(temp);
                return 1;
            }
        }
        else
        {
            prev=temp;
            temp= temp->next;
        }
    }
    return 0;
}

void main()
{

    add(100);
    add(200);
    Delete(100);
    Delete(200);
    Delete(300);
    display();
}

Question Number 23

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 24

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

Question Number 25

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

Question Number 26

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

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

Question Number 27

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,0x8
        ret
        End : add esp, 0x8
    }
    printf("%d %d", a, b);
}

Question Number 28

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

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

Question Number 29

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 30

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
        jmp Label3
        Label2 : mov b, 200
        ret
        Label3: mov a,200
    }
    printf("%d %d", a, b);
}

Question Number 31

After the execution of the particular loop given below, where is the final result stored in ? while(temp1!=NULL) { temp3=temp2; temp2=temp1; temp1=temp1->next; temp2->next=temp3; }
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 32

Give the output of the following code snippet :
void print(int num,int num2,...)
{
    int i;
    va_list marker;
    va_start(marker,num);
    while((--num) != 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 33

Give the output of the following code snippet :
int main()
{
    char ch = 'c';
    char *chptr = &ch;
    printf("%c",*chptr);
}

Question Number 34

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 35

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

Question Number 36

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

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

Question Number 37

Give the output of the following code snippet : Assume the input given is 100.25
void main()
{
    int i=3;
    int x;
    do
    {
        scanf("%d",&x);
        ungetc(x,stdout);
        printf("%d ",x);
        ungetc(x,stdin);
        i--;
    }
    while(i>3);
}

Question Number 38

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

Question Number 39

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

Question Number 40

Give the output of the following code snippet :
void f(int *p, int *q)
{
    p = q;
    *p = 2;
}
int i = 0, j = 1;
int main()
{
    f(&i, &j);
    printf("%d %d \n", i, j);
}

Question Number 41

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

Question Number 42

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

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

Question Number 43

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,len);
    puts(s2);
}

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

/* Test1.c */

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

}

/* Test2.c */

#include"Test1.h"

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

}

Question Number 45

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

Question Number 46

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;

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

Give the output of the following code snippet :
void func(char *s)
{
    int len=0;
    while(*s!='\0')
    {
        len++;
    }
    printf("%d",len);
}
void main()
{
    char str1[15]="Hello World";
    char *x;
    x=str1;
    func(x);
}

Question Number 48

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

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

Question Number 49

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 50

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

{
    int i = 5, a = 10;
    _asm
    {
        Label2:  cmp         dword ptr[i], 0

        je          Label1

        mov         eax, dword ptr[i]
        sub         eax, 1
        mov         dword ptr[i], eax

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

        jmp         Label2

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

Question Number 51

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

int main()
{

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

Question Number 52

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 53

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 54

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

Question Number 55

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 56

What do the following lines of code in the function indicate? while(temp!=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 57

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,12,fp)!=NULL)
    {
        printf("%s",x);
    }
    fclose(fp);

}

Question Number 58

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

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

Question Number 59

Give the output of the following code snippet :
int main()
{
    int i, j, k, prod = 0;
    _asm
    {
        mov         dword ptr[i], 1
        mov         dword ptr[j], 2
        mov         dword ptr[k], 1
        jmp         Label1
        Label3 : mov         eax, dword ptr[i]
        add         eax, 1
        mov         dword ptr[i], eax
        mov         ecx, dword ptr[j]
        add         ecx, 1
        mov         dword ptr[j], ecx
        mov         edx, dword ptr[k]
        add         edx, 1
        mov         dword ptr[k], edx
        Label1 : cmp         dword ptr[i], 3
        jg          Label2

        mov         eax, dword ptr[i]
        imul        eax, dword ptr[j]
        imul        eax, dword ptr[k]
        mov         dword ptr[prod], eax

        jmp         Label2

        jmp         Label3


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

Question Number 60

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 61

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 62

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

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

}

Question Number 63

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 64

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 65

Give the output of the following code snippet :
void main()
{
    int i = 12, 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
        mov         dword ptr[a], 12Ch

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

Question Number 66

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 67

Give the output of the following code snippet :
int main()
{
    struct Temp
    {
        int one:2;
    };
    struct Temp var = {1};
    printf("%d\n", var.one);
    return 0;
}

Question Number 68

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

}
void main()
{
    char s[20];
    s=func();
    printf("%s",s);
}

Question Number 69

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

Question Number 70

Give the output of the following code snippet : Assume the contents of the file 'Test.txt' is Hello World
void main()
{
    char ch;
    char str[10];
    int count=0;
    FILE *fp;
    int i=0;
    fp=fopen("Test.txt","r");
    while((ch=getc(fp))!=EOF)
    {
        if(ch=='\n'|| ch==' ')
        {
            i++;
        }

    }
    printf("%d",i);
    fclose(fp);
}

Question Number 71

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

Question Number 72

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 73

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 74

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

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

Question Number 75

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

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

Question Number 76

Give the output of the following code snippet :
void main()
{
    char str[]="Hello world";
    char *str1="Hello world";
    if(strcmp(str,str1)==0)
        printf("True");
    else
        printf("False");
}

Question Number 77

Give the output of the following code snippet :
typedef struct
{
    int a;
} Temp;

void main()
{
    Temp t1;
    t1.a=100;
    printf("%d",t1.a);
}

Question Number 78

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

Question Number 79

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

Question Number 80

Give the output of the following code snippet :
typedef void v;
v func(int,int);
void main()
{
    func(10,10);
}
v func(int x,int y)
{
    printf("%d",x+y);
}

Question Number 81

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

/* Test1.c */

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

}

/* Test2.c */

#include "Test1.h"
void main ()
{
    extern int value;
    printf ( "Output = %d\n", value );
}

Question Number 82

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 83

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 84

Give the output of the following code snippet :
void main()
{
    int i = 0, a = 10;
    _asm
    {
        Label2:  cmp         dword ptr[i], 2
        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], 5
        jne         Label2
    }

    printf("%d", a);
}

Question Number 85

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

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

Question Number 86

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

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

}

Question Number 87

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

Question Number 88

Give the output of the following code snippet :
union p
{
    int x;
    char y;
};
int main()
{
    union p p1;
    union p *ptr1 = &p1;
    ptr1->x=100;
    ptr1->y='C';
    printf("%c\n",ptr1->x);
}

Question Number 89

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 edx
        add esp,8

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

Question Number 90

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);
    puts(s2);
}

Question Number 91

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

Question Number 92

Give the output of the following code snippet :
struct student
{
    int mark1;
    char *name1;

};
void main()
{
    struct student stud;
    stud.mark1=100;
    stud.name1="Jenn";
    struct student *s=&stud;
    printf("%s",s->stud.name1);
}

Question Number 93

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

Question Number 94

Give the output of the following code snippet :

void main()
{
    int a=50,c=10,b=40;
    _asm
    {
        mov eax,40
        mov ebx,a
        sub eax,dword ptr[b]
        jae Label2
        mov b,eax
        Label2:
        mov ecx,dword ptr[a]
        cmp eax,ecx
        jne Label1
        add eax,dword ptr[b]
        mov c,eax

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

Question Number 95

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

Question Number 96

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

Question Number 97

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 98

Give the output of the following code snippet :
void f(int i)
{
    printf("%d\n", i);
}
void (*func)(void) = f;
int main(int argc, char *argv[])
{
    func(10);
    return 0;
}

Question Number 99

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 100

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

Question Number 101

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 102

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

void func();
/* Test1.c */

#include "Test1.h"

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

}


/* Test2.c */
#include "Test1.h"
static int value;
void main ()
{
    func();
    printf ( "Output = %d\n", value );
}

Question Number 103

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

Question Number 104

Give the output of the following code snippet :
void func(int *p,int count)
{
    for(int i=0; i< count; i++)
        printf("%d ", p[i]);
}
int main()
{
    int arry[5]= {1,2,3,4,5};
    func(arry,5);
}

Question Number 105

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

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

Question Number 106

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

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


        mov         eax, dword ptr[sum]
        add         eax, dword ptr[a]
        mov         dword ptr[sum], eax

        mov         ecx, dword ptr[i]
        sub         ecx, 1
        mov         dword ptr[i], ecx

        mov         edx, dword ptr[j]

        add         edx, 1
        mov         dword ptr[j], edx

        mov         eax, dword ptr[a]
        add         eax, dword ptr[j]
        mov         dword ptr[a], eax

        jmp         Label2

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

}

Question Number 107

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);
    printf("%d",i);
    va_end(marker);
}
int main()
{
    print("Start ",2,4,-1);
}

Question Number 108

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

}

Question Number 109

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;
    printf ( "Output = %d\n", ++value );

}


/* Test3.c */

#include "Test1.h"

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

Question Number 110

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 111

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

Question Number 112

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

Question Number 113

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 114

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 115

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

Question Number 116

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, 1
        mov         dword ptr[a], eax
        mov         ecx, dword ptr[sum]
        sub         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 117

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

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

}

Question Number 118

Give the output of the following code snippet :
void main()
{
    int a=20,c=10,b=30;
    _asm
    {
        mov eax,10
        mov ebx,a
        sub eax,ebx
        jb Label1
        mov b,200
        mov c,100

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

Question Number 119

Give the output of the following code snippet :
void func(float *i)
{
    i=200.5;
}

int main()
{
    float i=100.25;
    func(&i);
    printf("%.2f ", i);
}

Question Number 120

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

Question Number 121

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 122

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 123

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));
    double e= (c > d) ? c : d;

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

Question Number 124

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 dword ptr[b]
        push eax
        push ebx
        mov ecx, esp
        pop dword ptr[b]
        mov ebx, dword ptr[b]
        sub ecx, eax
        mov a, ecx
        mov b, ebx

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

Question Number 125

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

Question Number 126

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

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;

}

int Delete(int num)
{
    struct node *temp, *prev;
    temp=head;
    while(temp!=NULL)
    {
        if(temp->data==num)
        {
            if(temp==head)
            {
                head=temp->next;
                free(temp);
                return 1;
            }
            else
            {
                prev->next=temp->next;
                free(temp);
                return 1;
            }
        }
        else
        {
            prev=temp;
            temp= temp->next;
        }
    }
    return 0;
}

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

Question Number 127

Give the output of the following code snippet :
void first()
{
    printf("Hello World");
}
void main()
{
    void (*ptr)();
    ptr=&first;
    ptr();
}

Question Number 128

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
        jne End

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

Question Number 129

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

Question Number 130

Consider the given lines of code : What does the line below signify? if(head == NULL)
void add( int num )
{
    struct node *temp;
    if (head== NULL)
    {
        head=temp;
        head->next=NULL;
    }
    temp=(struct node *)malloc(sizeof(struct node));
    temp->data=num;
    temp->next=head;
    head=temp;

}

Question Number 131

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 132

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

Question Number 133

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].y,++p[1].y);
}
int main()
{
    struct point p1[] = {1, 2, 3, 4};
    fun(p1);
}

Question Number 134

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 ");
        else
            printf("World");
        break;
    }

}

Question Number 135

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],sizeof(arry));
}

Question Number 136

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

int main()
{
    union Test st1, *st2;
    st1.str='D';
    st2 = &st1;
    st1.str = 'J';
    printf("%c",st2->str);
}

Question Number 137

Give the output of the following code snippet :
void main()
{
    int a=20,c=10,b=30;
    _asm
    {
        mov eax,60
        mov ebx,b
        sub eax,ebx
        jnb Label1
        mov b,200
        mov c,100

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

Question Number 138

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

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

Question Number 139

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

Question Number 140

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 141

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 142

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 143

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

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;

}

int Delete(int num)
{
    struct node *temp, *prev;
    temp=head;
    while(temp!=NULL)
    {
        if(temp->data==num)
        {
            if(temp==head)
            {
                head=temp->next;
                free(temp);
                return 1;
            }
            else
            {
                prev->next=temp->next;
                free(temp);
                return 1;
            }
        }
        else
        {
            prev=temp;
            temp= temp->next;
        }
    }
    return 0;
}

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

Question Number 144

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

Question Number 145

Give the output of the following code snippet :
int main()
{
    int y=100;
    const int* z=&y;

    y+=1;
    printf("%d",*z);

}

Question Number 146

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

{
    int i = 3, a = 10, j = 5;
    _asm
    {
        Label2:   cmp         dword ptr[i], 5
        jl          Label1
        jmp         Label2
        Label1 : mov         eax, dword ptr[j]
        imul        eax, dword ptr[j]
        add         eax, dword ptr[a]
        mov         dword ptr[a], eax
        mov         ecx, dword ptr[a]
        sub         ecx, 1
        mov         dword ptr[a], ecx
        mov         edx, dword ptr[j]
        add         edx, 1
        mov         dword ptr[j], edx
        mov         eax, dword ptr[i]
        add         eax, 1
        mov         dword ptr[i], eax
    }

    printf("%d", a);
}

Question Number 147

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

Question Number 148

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 149

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

Question Number 150

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 151

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","w");
    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 152

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 153

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->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);
    Display();
    ReverseList();
    Display();
}

Question Number 154

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

Question Number 155

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 156

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

{
    int a = 0, b =0, c=0;
    __asm
    {
        push 100
        push 200
        push 500
        mov ebx,300
        mov eax, 400
        call label1
        add esp, 12
        jmp Label2
        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]
        add eax,ebx
        mov c,eax
        ret
    }
Label2:
    printf("%d %d %d", a, b, c);

}

Question Number 157

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

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

Question Number 158

Give the output of the following code snippet :
void main()
{
    int a=20,c=50,b=20;
    _asm
    {
        mov eax,20
        mov ebx,b
        cmp eax,dword ptr[c]
        jg Label2
        mov edx,dword ptr[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 159

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->next!=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 160

Give the output of the following code snippet :
void main()
{
    char *str="100.25";
    char *str2="200.25";
    int x;
    x=atoi(str)+atoi(str2);
    printf("%d",x);
}

Question Number 161

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 162

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

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

Question Number 163

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

}

Question Number 164

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

Question Number 165

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[0].Cobj.Id);
}

Question Number 166

Give the output of the following code snippet:
int main()
{
    char *arg[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
    printf("%c", **arg);
}

Question Number 167

Give the output of the following code snippet :
#define row 3
#define col 3
void main()
{
    int (*arr)[col];
    arr=(int (*)[col])malloc(sizeof(row*sizeof(*arr)));
    printf("%d",sizeof(arr));
    free(arr);
}

Question Number 168

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 169

Give the output of the following code snippet :
struct student
{
    int mark1;
    char *name1;

};
void main()
{
    struct student stud;
    stud.mark1=100;
    stud.name1="Jenn";
    struct student s=&stud;
    printf("%s",s->name1);
}

Question Number 170

Consider the given statement from the below lines of code: What does it indicate? Head=root;
struct node *root;
root = (struct node *) malloc( sizeof(struct node) );
root->next = 0;
root->x = 5;
Head=root;

Question Number 171

Give the output of the following code snippet :
int main()
{
    enum days {Mon=-1, Tue, Wed=6, Thu, Fri, Sat,Sun};
    printf("%d",Tue);
    return 0;
}

Question Number 172

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 173

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

}

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

Question Number 174

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 175

Give the output of the following code snippet :
float *func()
{
    float *s;
    s=(float*)malloc(1*sizeof(float));
    *s=100.25;
    return s;
}
void main()
{
    float *s;
    s=func();
    printf("%.3f",*s);
}

Question Number 176

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

Question Number 177

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 178

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 179

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 180

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

Question Number 181

Give the output of the following code snippet :
typedef struct student
{
    char *a;
} stud;
void main()
{
    struct s;
    s.a = "Hello";
    printf("%s", s.a);
}

Question Number 182

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 183

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,ebx
        je Label2
        mov b,eax
        Label2:
        mov ecx,c
        and eax,ecx
        mov c,eax

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

Question Number 184

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

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

Question Number 185

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

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

Question Number 186

Consider the given statement from the below lines of code: What does it indicate? root->prev=NULL;
struct node *root;
root = (struct node *) malloc( sizeof(struct node) );
root->next = NULL;
root->x = 5;
root->prev=NULL;
Head=root;

Question Number 187

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

Question Number 188

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
        mov c, eax
    }
    printf("%d", c);
}

Question Number 189

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

Question Number 190

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

Question Number 191

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 192

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

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

}

/* Test2.c */

#include "Test1.h"
void main ()
{
    extern int value;
    printf ( "Output = %d\n", value );
}

Question Number 193

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

{
    int a = 0, b =0, c=0;
    __asm
    {
        push 100
        push 200
        mov ebx,300
        mov eax, 400
        call label1
        add esp, 8
        jmp Label2
        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:
    printf("%d %d %d", a, b, c);

}

Question Number 194

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

Question Number 195

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

Question Number 196

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
        mov         dword ptr[a], 12Ch

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

Question Number 197

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

Question Number 198

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

Question Number 199

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

}

Question Number 200

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 201

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

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

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

Question Number 202

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 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
    }
    printf("%d %d %d", a, b, c);

}

Question Number 203

Give the output of the following code snippet :
char *func(unsigned int num,int base)
{
    static char bffer[33];
    char *p=&bffer[sizeof(bffer)-1];
    *p='\0';
    do
    {
        *--p="0123456789"[num%base];
        num/=base;
    }
    while(num!=0);
    return p;
}
void main()
{
    char *str;
    str=func(9,8);
    printf("%s",str);
}

Question Number 204

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

Question Number 205

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 206

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 207

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

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

Question Number 208

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 209

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 210

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

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

Question Number 211

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

Question Number 212

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("%d ", atoi(argv[i]));
    return 0;
}

Question Number 213

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 214

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;
    printf("%c %d",argv[2][i],i);
}

Question Number 215

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 u1 = {2};
    printf("%d\n", u1.p.y);
}

Question Number 216

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 217

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

Question Number 218

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

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

Question Number 219

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 220

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};
    fun(&p1);
}
void fun(struct point *p)
{
    printf("%d\n", p -> x++);
}

Question Number 221

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,dword ptr[c]
        jz Label2
        mov b,eax
        Label2:
        mov ecx,c
        cmp eax,ecx
        jns Label1
        and eax,dword ptr[b]
        mov c,eax

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

Question Number 222

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


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

Question Number 223

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

Question Number 224

Give the output of the following code snippet :
void main()
{
    int y,z;
    int x=printf("%d HelloWorld\n");
    printf("%d",x);
}

Question Number 225

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 100
        push 200
        push 500
        mov ebx,300
        mov eax, 400
        mov ecx,600
        call label1
        add esp, 12
        jmp Label2
        label1:
        mov d,eax
        mov eax, dword ptr[esp + 4]
        mov a, eax
        mov eax, dword ptr[esp + 8]
        mov b, eax
        mov eax, dword ptr[esp + 12]
        sub eax,ebx
        and ebx,ecx
        mov c,eax
        mov d,ebx
        ret
    }
Label2:
    printf("%d %d %d %d", a, b, c, d);

}

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)+2);
        i+=2;
    }
}

Question Number 227

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);
    Display();
    SortList();
    Display();

}

Question Number 228

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 229

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 230

Give the output of the following code snippet :
int main()
{
    char *s;
    char buf [] = "Hello World";
    s = strchr (buf, 'l');
    if (s != NULL)
        printf ("Found %s", s);
    else
        printf("Not found");
    return 0;
}

Question Number 231

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

Question Number 232

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

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

Question Number 233

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

Question Number 234

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

}
/* Test1.c */

void func();


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

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

Question Number 235

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         eax, dword ptr[a]
        or          eax, 30h
        mov         ecx, dword ptr[sum]
        shl         ecx,1
        or          ecx,dword ptr[a]
        mov         dword ptr[sum], ecx
    }
    printf("%d", sum);
    return 0;
}

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

Question Number 236

Give the output of the following code snippet :
typedef struct Node
{
    int data;
    struct Node *next;
} node;
node *HeadNode=0;
void print(node *pointer)
{
    if(pointer==NULL)
        return;
    printf("%d ",pointer->data);
    print(pointer->next);
}
void main()
{
    node *start;
    start = (node *)malloc(sizeof(node));
    start -> data=100;
    start -> next = NULL;
    HeadNode=start;

    start = (node *)malloc(sizeof(node));
    start -> data=200;
    start -> next = NULL;
    HeadNode->next=start;

    start = (node *)malloc(sizeof(node));
    start -> data=300;
    start -> next = NULL;
    HeadNode->next->next=start;
    print(start);
}

Question Number 237

Give the output of the following code snippet :
void func(float);
void (*fptr)(float) = func;
int main()
{
    fptr(10);
}
void func(float i)
{
    printf("%.1f ", i);
}

Question Number 238

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

Question Number 239

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

Question Number 240

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

Question Number 241

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;
    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 242

Consider the given lines of code : What does the line below signify? 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; }
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 243

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

Question Number 244

Give the output of the following code snippet :
void main()
{
    char *s1="Hello";
    char *s2="World";
    int b=200;
    float a=100.25;
    char str[20];
    sprintf(str,"%d",a+b);
    puts(str);
}

Question Number 245

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

Question Number 246

Give the output of the following code snippet :
#define CONCAT(x,y,z) printf("%s %s %s",x,y,z);
int main()
{
    char *str1="Hello";
    char *str2="World";
    char *str3="Program";
    CONCAT(str1,str2,str3);
}

Question Number 247

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 248

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

Question Number 249

Give the output of the following code snippet :
void main()
{
    FILE *fp,*fp1;
    char x;
    fp = fopen("Test.txt","w+");
    fputs("Hello World Program", 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 250

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

Question Number 251

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 252

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 253

What do the following lines of code indicate? if(temp==head) { head=temp->next; free(temp); }
int Delete(int num)
{
    struct node *temp, *prev;
    temp=head;
    while(temp!=NULL)
    {
        if(temp->data==num)
        {
            if(temp==head)
            {
                head=temp->next;
                free(temp);
                return 1;
            }
            else
            {
                prev->next=temp->next;
                free(temp);
                return 1;
            }
        }
        else
        {
            prev=temp;
            temp= temp->next;
        }
    }
    return 0;
}

Question Number 254

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

{
    int a = 0, b =0, c=0;
    __asm
    {
        push 100
        push 200
        mov ebx,300
        mov eax, 400
        call label1
        add esp, 8
        jmp Label2
        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]
        add eax,ebx
        mov c,eax
        ret
    }
Label2:
    printf("%d %d %d", a, b, c);

}

Question Number 255

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