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.
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);
}
Give the output of the following code snippet :
void main()
{
int row=2,col=2;
int **arr;
int i,j;
arr=(int*)malloc(2*2*sizeof(int));
for(i=0; i< row; i++)
{
for(j=0; j< col; j++)
{
arr[i*col+j]=i*i;
printf("%d ",arr[i*col+j]);
}
}
}
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", ptr1->x);
else
printf("False");
}
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);
}
Give the output of the following code snippet :
int main()
{
int (*p)[5];
int a[][5]= {1,2,3,4,5,6};
p=a;
int *q;
q=(int*)a;
printf("%d %d %d",**p+3,*q+5,**a);
}
Give the importance of the below statement in the given code :
if(temp1->x > temp2->x)
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;
}
}
}
Give the output of the following code snippet :
int main()
{
enum state {working};
enum result {failed=0, passed};
printf("%d",failed);
}
Give the output of the following code snippet :
void func(struct emp*);
struct emp
{
char name[20];
int age;
};
int main()
{
struct emp e = {"Jenn", 20};
func(&e);
printf("%s %d", e.name, e.age);
}
void func(struct emp *p)
{
p ->age=p->age+2;
}
Give the output of the following code snippet :
typedef union ut
{
int Ival;
float fval;
char s[20];
};
void main()
{
ut u, *pu, au[5];
printf("%d",sizeof(au[1]));
}
Give the output of the following code snippet :
void main()
{
FILE *fp,*fp1;
char x;
fp = fopen("Test.txt","w+");
fputs("Hello", 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);
}
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"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
int value = 100;
void main ()
{
func1();
func();
}
Give the output of the following code snippet :
union p
{
int x;
char y;
}
int main()
{
union p t= {1};
printf("%d\n", t.x);
}
Give the output of the following code snippet who's solution configuration has been set to the DEBUG mode :
int main()
{
int a = 200, b = 100, c = 2;
_asm
{
mov eax, esp
mov ebx, 10
push eax
push ebx
mov ecx, esp
mov ebx, dword ptr[b]
sub ecx, eax
mov a, ecx
mov b, ebx
pop ebx
add esp,4
}
printf("%d %d", a, b);
}
Give the output of the following code snippet :
void main()
{
int a=20,c=10,b=10;
_asm
{
mov eax,10
mov ebx,dword ptr[c]
cmp eax,ebx
jnbe Label2
shr eax,2
and eax,dword ptr[a]
mov b,eax
Label2:
mov ecx,dword ptr[a]
sub ecx,ebx
jne Label1
and eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet who's solution configuration has been set to the DEBUG mode :
int main()
{
int a = 10;
int b = 20;
int c = 30;
_asm
{
mov eax, 10
push eax
push a
push b
push c
mov ebx, dword ptr[esp]
mov a, ebx
pop a
pop b
pop c
add esp,4
}
printf("%d %d %d", a, b, c);
}
Which of the following line of code is responsible for the actual reversal of the links in the particular program?
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;
}
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 );
}
Give the output of the following code snippet :
int main()
{
int x=20,y=10,z=20;
int a= !x==10 && z==30;
int b= x&y;
int c= x-- > y++;
printf("%d %d %d",a,b,c);
}
Give the output of the following code snippet :
struct student
{
int mark1;
char name1;
char name2;
char name3;
char name4;
};
void main()
{
struct student stud;
struct student *s=&stud;
printf("%d",sizeof(stud));
}
Give the output of the following code snippet :
typedef union ut
{
int Ival;
float fval;
char s[20];
};
void main()
{
ut u, *pu, au[5];
printf("%d",sizeof(u));
}
Give the output of the following code snippet run with the following commandline arguments:
>Testfile.c 1 2
/* Testfile.c */
int main(int argc, char *argv[])
{
int j;
j = argv[1] + argv[2];
printf("%d", j);
return 0;
}
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,&arr+1);
}
Give the output of the following code snippet :
void main()
{
int *k = 0;
int **m = &k;
printf("%d %d", k, *m);
}
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);
}
Give the output of the following code snippet :
void main()
{
int i = 0, a = 10;
_asm
{
Label2: cmp dword ptr[i], 0
jle Label1
mov eax, dword ptr[a]
add eax, 5
mov dword ptr[a], eax
Label1 : mov ecx, dword ptr[i]
add ecx, 3
mov dword ptr[i], ecx
cmp dword ptr[i], 9
jne Label2
}
printf("%d", a);
}
Give the output of the following code snippet :
int main()
{
float *ptr;
int num = 10;
ptr = &num ;
printf("%d",*ptr);
}
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 = 100;
void func();
/* Test1.c */
#include"Test2.h"
void func()
{
printf("Output = %d\n",value);
}
/* Test2.c */
#include"Test2.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
void main ()
{
func1();
func();
}
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);
ungetc(x,stdout);
printf("%d ",x);
break;
ungetc(x,stdin);
i--;
}
}
Give the output of the following code snippet :
int main()
{
int i, *p, q;
_asm
{
mov dword ptr[i], 1Dh
lea eax, [i]
mov dword ptr[p], eax
mov ecx, dword ptr[p]
mov edx, dword ptr[ecx]
add edx, 15
mov eax, dword ptr[p]
add edx, dword ptr[i]
mov dword ptr[eax], edx
mov ecx, dword ptr[p]
mov edx, dword ptr[ecx]
mov dword ptr[q], edx
mov eax, dword ptr[p]
sub eax, 10
mov dword ptr[p], eax
}
printf("%d", q);
}
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);
}
Give the output of the following code snippet :
int main()
{
int x=100,y=200,z=0;
x>300?y=20:x=300;
x< 300?x=40:z=100;
printf("%d %d %d",x,y,z);
return 0;
}
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"
void func1()
{
printf ( "Output = %d\n", ++value );
func();
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
int value = 100;
void main ()
{
func1();
}
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");
}
Give the importance of the following line of code from the given program:
temp5=temp2->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;
}
}
}
Give the output of the following code snippet :
int f(int i)
{
int sum=0;
_asm
{
mov dword ptr [sum],14h
mov eax,dword ptr [i]
add eax,0Ah
mov dword ptr [i],eax
mov ecx,dword ptr [sum]
imul 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);
}
Give the output of the following code snippet :
void main()
{
int a=10,c=-10,b=10;
_asm
{
mov eax,10
mov ebx,b
sub eax,dword ptr[b]
jnle Label2
mov edx,dword ptr[c]
or 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);
}
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]
or ecx,dword ptr[b]
dec ecx
mov a,ecx
}
printf("%d",c);
}
Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
static int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
int value = 100;
void func()
{
value=200;
printf ( "Output = %d\n", ++value );
func1();
}
/* Test2.c */
#include "Test1.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
void main ()
{
func1();
func();
}
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;
}
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=1001;
printf("%d",s.no);
}
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;
}
Give the output of the following code snippet :
struct temp
{
int a;
} s[5];
void func(struct temp*)
{
s[0].a = 5;
printf("%d ", s[0].a);
}
void main()
{
func(s);
printf("%d\t", s[0].a);
}
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 */
static int value = 100;
void func();
/* Test1.c */
#include "Test1.h"
int value;
void func()
{
value = 200;
printf ( "Output = %d\n", ++value );
}
/* Test2.c */
#include "Test1.h"
void main ()
{
func();
printf ( "Output = %d\n", ++value );
}
Give the output of the following code snippet :
void main()
{
int a=50,c=10,b=10;
_asm
{
mov eax,35
mov ebx,a
sub eax,dword ptr[b]
jae Label2
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp eax,ecx
je Label1
sub eax,dword ptr[b]
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
const int* func(int i)
{
int x=i;
const int *ptr=&x;
return (ptr);
}
void main()
{
int a=10,b=20;
const int *qtr=func(a);
qtr=&b;
b++;
printf("%d",*qtr);
}
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);
}
Give the output of the following code snippet :
void main()
{
int a=30,c=20,b=40;
_asm
{
mov eax,20
mov ebx,dword ptr[c]
cmp eax,ebx
jnl Label2
add eax,10
and eax,dword ptr[a]
mov b,eax
Label2:
mov ecx,dword ptr[a]
sub ecx,ebx
jns Label1
and eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
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);
}
Give the output of the following code snippet :
void main()
{
char str[]="Hello world";
char *str1="Hello world";
if(str==str1)
printf("True");
else
printf("False");
}
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\n", ptrary[]->name);
return 0;
}
Give the output of the following code snippet :
void main()
{
char x,y;
printf("%d ",(100*-1));
}
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);
}
Give the output of the following code snippet :
void func(int arr[][])
{
**arr++;
printf("%d ",**arr);
}
int main()
{
int arry[][5]= {1,2,3,4,5,6};
func(arry);
printf("%d ",**arry+3);
}
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);
}
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;
}
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);
}
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);
}
Give the output of the following code snippet :
int main()
{
int a = 20;
int b = 20;
if ((a >> 1) == (a * 2))
printf("True ");
else
printf("False");
}
Give the output of the following code snippet :
int main()
{
int a,b=2,c=10;
_asm
{
mov dword ptr[a],0
mov eax,dword ptr[c]
mov dword ptr[b],20
add ecx,dword ptr[c]
or ecx,eax
inc ecx
mov a,ecx
}
printf("%d",a);
}
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);
}
Give the output of the following code snippet :
struct student
{
char *name;
int age;
};
struct student s[2];
void main()
{
s[0].name = "Jenn ";
s[1] = s[0];
printf("%d %d", s[0].age, s[1].age);
}
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);
}
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);
}
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
jz Label2
mov b,45
Label2:
mov ecx,dword ptr[a]
sub eax,ecx
jz Label1
and eax,dword ptr[c]
mov c,eax
}
Label1: printf("%d %d",b,c);
}
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);
}
Give the output of the following code snippet :
int main()
{
int arry[3][3]= {1,2,3,4,5,6};
printf("%d",**arry);
}
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);
}
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=func(p1);
printf("%d\n", p1.y);
}
struct point func(struct point p)
{
p.y=20;
return p;
}
Give the output of the following code snippet :
int main()
{
int i = 0, a = 105;
_asm
{
Label3: cmp dword ptr[i], 3
jge Label2
mov eax, dword ptr[a]
add eax, 0Ah
mov dword ptr[a], eax
mov ecx, dword ptr[i]
add ecx, 1
mov dword ptr[i], ecx
cmp dword ptr[a], 1Eh
jne Label1
jmp Label2
Label1 : jmp Label3
}
Label2: printf("%d %d", a, i);
}
Give the output of the following code snippet :
struct student
{
char *name;
};
void main()
{
struct student s, m;
s.name = "Abby";
m = &s;
printf("%s %s", s.name, m.name);
}
Give the output of the following code snippet :
void main()
{
int a=10,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);
}
Give the output of the following code snippet :
int main()
{
char *str = "Hello world";
char strary[] = "Hello world";
printf("%d %d\n", strlen(str), strlen(strary));
return 0;
}
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]
add eax, 26h
mov dword ptr[a], eax
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 40h
mov ecx, 4
shl ecx, 0
mov edx, dword ptr[ebp + ecx - 28h]
call edx
add esp, 4
}
}
Consider the following lines of code from the given program : What does temp2 store?
temp3=temp2;
temp2=temp1;
temp1=temp1->next;
void ReverseList()
{
node *temp1,*temp2,*temp3;
temp1=Head;
temp2=NULL;
while(temp1!=NULL)
{
temp3=temp2;
temp2=temp1;
temp1=temp1->next;
temp2->next=temp3;
}
Head=temp2;
}
Give the output of the following code snippet :
int main()
{
int i=10,*p;
p=&i;
++*p;
printf("%d",*p + ++*p);
}
Give the output of the following code snippet :
int sum(int first,...)
{
int sum=0, count=0,i=first;
va_list marker;
va_start(marker,first);
while(i!=-1)
{
sum+=i;
count++;
i=va_arg(marker,int);
}
va_end(marker);
return sum;
}
int main(int argc, char *argv[])
{
printf("%d",sum(2,3.5,4.5,-1));
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
int z;
} ptr;
int main()
{
int* offset=&(((point*)0)->y);
printf("%d",offset);
}
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);
}
Give the output of the following code snippet :
void main()
{
int a[10];
int b=sizeof(*a);
printf("%d",b);
}
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);
}
Give the output of the following code snippet :
void main()
{
int row=2,col=2;
int *arr;
int i,j;
arr=(int*)calloc(row*col,sizeof(int));
for(i=0; i< row; i++)
{
for(j=0; j< col; j++)
{
arr[i*col+j]=i*i;
printf("%d ",arr[i*col+j]);
}
}
}
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);
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b = 0;
__asm
{
mov eax,Label1
call eax
mov ebx,Label2
jmp ebx
Label1 :
mov a, 100
Label2 : mov b, 200
}
printf("%d %d", a,b);
}
Give the output of the following code snippet :
void main()
{
char s1[]="Hello";
char *s2;
int b=200;
char str[20];
sprintf(s2,"%.*s",8,s1);
puts(s2);
}
Give the output of the following code snippet :
typedef struct stud
{
int no;
int no2;
} stud;
void main()
{
stud s;
s.no=10;
printf("%d",s.no);
}
Give the output of the following code snippet :
int main()
{
int a = 10;
int b = 20;
int c = 30;
_asm
{
mov eax, 10
push eax
push a
push b
push c
mov ebx, dword ptr[esp]
mov a, ebx
pop b
pop c
add esp, 0x10
}
printf( "%d %d %d",a,b,c);
}
Give the output of the following code snippet :
void main()
{
int a=10,b=20,c=30;
unsigned int d=2;
int x=10,y=20,z=30;
x=a | b >> c || d;
y >>= 3;
z = y>> 2;
printf("%d %d %d",x,y,z);
}
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 );
}
Give the output of the following code snippet :
void main()
{
char arry[10]="Hello";
char str[15]="World";
char* const ptr=str;
*str='Y';
printf("%s",str);
}
Give the output of the following code snippet :
int main()
{
int i, *p, q;
_asm
{
mov dword ptr[i], 3
lea eax, [i]
mov dword ptr[p], eax
mov ecx, dword ptr[p]
mov edx, dword ptr[ecx]
add edx, 2
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, 4
mov dword ptr[p], eax
}
printf("%d", q);
}
Give the output of the following code snippet :
void func(char *s)
{
printf("%c",*(s+8));
}
void main()
{
char str[]="Hello World";
char *str1="Hello world";
if(strcmp(str,str1)==0)
func(str);
else
func(str1);
}
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);
}
Which of the following operators is used to access the address of an object?
< NIL>
Give the output of the following code snippet :
struct temp
{
int a;
} s;
void func(struct temp)
{
s.a = 5;
printf("%d ", s.a);
}
void main()
{
func(s);
printf("%d\t", s.a);
}
The subscript for a two dimensional array can be written as?
< NIL>
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
sub ebx,eax
add eax,ebx
mov a,eax
mov b,ebx
}
printf("%d %d",a,b);
}
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!=0)
{
i=va_arg(marker,int);
printf("%d ",i);
}
va_end(marker);
return sum;
}
int main(int argc, char *argv[])
{
sum(2,4,6,-1);
}
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);
}
Give the output of the following code snippet :
void main()
{
int a=20,c=10,b=10;
_asm
{
mov eax,40
mov ebx,dword ptr[c]
sub eax,ebx
jnbe Label2
shr eax,2
and eax,dword ptr[a]
mov b,eax
Label2:
mov ecx,dword ptr[a]
sub ecx,ebx
je Label1
and eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
struct p
{
int x;
char y;
};
int main()
{
struct p p1[] = {1, 92, 3, 96};
struct p *ptr1 = p1;
printf("%d ",p1[1].x);
}
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
or ebx,ecx
inc ebx
mov a,ecx
mov b,ebx
}
printf("%d %d",a,b);
}
Give the output of the following code snippet :
int main()
{
int *ptr,x;
ptr = &x;
*ptr = 0;
*ptr += 5;
printf("%d %d\n", x,*ptr);
return 0;
}
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("%s", *++argv+2 );
return 0;
}
Give the output of the following code snippet :
void main()
{
int arr[]= {10,20,30,40};
int i=5,j=3;
int x=10;
while(i>=1)
{
if( j & arr[i])
x++;
i--;
}
printf("%d",x);
}
Give the output of the following code snippet :
struct stud
{
int age;
char *name;
};
void main()
{
struct stud s;
struct stud *temp;
temp->name="Jenn";
temp->age=22;
printf("%s",temp->name);
}
Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
static int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
int value = 300;
void func()
{
value=200;
printf ( "Output = %d\n", ++value );
func1();
}
/* Test2.c */
#include "Test1.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
void main ()
{
func1();
func();
}
Give the output of the following code snippet :
int main()
{
enum Days {SUN,MON,TUES,WED,THURS,FRI,SAT};
typedef enum Days EDays;
EDays day=MON;
EDays day2=FRI;
printf("%d %d",day,day2);
}
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[sum]
add ecx, dword ptr[i]
mov dword ptr[sum], ecx
jmp Label3
}
Label2: printf("%d", sum);
}
Give the output of the following code snippet :
union temp
{
double a;
int b[10];
char c;
};
void main()
{
union temp t;
printf("%d",sizeof(t));
}
Give the output of the following code snippet :
int main()
{
int a = 0;
int b = 0;
int c = 0;
_asm
{
mov eax, 100
push eax
mov ebx, 1000
push ebx
mov ecx, 10000
push ecx
mov ebx, dword ptr[esp+8]
mov a, ebx
mov ebx, dword ptr[esp+4]
mov b, ebx
mov ebx, dword ptr[esp]
mov c, ebx
add esp, 0x10
}
printf( "%d %d %d", a, b, c );
}
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",(int)a+b);
puts(str);
}
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(ptr1));
if (x == sizeof(int))
printf("%d\n", p1[4].x);
else
printf("%d\n", p1[2].y);
}
Give the output of the following code snippet :
typedef struct stud *ptr;
typedef struct emp *qtr;
struct stud
{
int no;
int no2;
struct stud *link;
};
struct emp
{
int id;
struct stud *link2;
};
void main()
{
qtr s=(emp *)malloc(sizeof(struct emp));
s->id=10;
printf("%d",s->id);
}
The & operator cannot be used to applied to which of the following?
< NIL>
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);
}
Give the output of the following code snippet :
void main()
{
char *str="1001";
int x;
x=atoi(str);
printf("%d",x);
}
Give the output of the following code snippet :
void func(char **a)
{
printf("%s",*(a+5));
}
void main()
{
char *str[15]= {"This","is","a","Hello","World","Program"};
char *x;
x=str[4];
str[4]=str[5];
str[5]=x;
func(str);
}
Give the output of the following code snippet :
int main()
{
int ary[2][3][4], j = 20;
ary[0][0] = &j;
printf("%d\n", *ary[0][0]);
}
Give the output of the following code snippet :
int main()
{
int i = 0, a = 105;
_asm
{
mov eax, dword ptr[i]
add eax, 1
mov dword ptr[i], eax
Label2 : cmp dword ptr[i], 0
jne Label1
mov ecx, dword ptr[i]
sub ecx, 1
mov dword ptr[i], ecx
jmp Label2
} Label1:
printf("%d", a);
}
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="0123456789abcdef"[num%base];
num/=base;
}
while(num!=0);
return p;
}
void main()
{
char *str;
str=func(100,16);
printf("%s",str);
}
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 */
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"
int arg =20;
void main ()
{
func(arg);
}
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
push 100
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, 0x10
}
printf( "%d %d %d",a,b,c);
}
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("%d\n",ptr1->x);
}
Give the output of the following code snippet :
int main()
{
int *ptr=0;
printf("%d",ptr);
}
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);
}
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 */
void func()
{
int value = 200;
printf ( "Output = %d", value );
}
/* Test2.c */
#include"Test1.h"
extern int value;
void main ()
{
func();
printf ( "Output = %d\n", value );
}
Give the output of the following code snippet :
struct student
{
char *name;
};
void main()
{
struct student s[2];
s[1].name = s[0].name = "Jenn";
printf("%s %s", s[0].name, s[1].name);
}
Give the output of the following code snippet :
struct node
{
int data;
struct node *next;
struct node *prev;
}*head;
void func( int num )
{
struct node *temp,*temp2;
if (head== NULL)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=NULL;
temp->prev=NULL;
head=temp;
}
else
{
temp=head;
while (temp->next!=NULL)
temp=temp->next;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->data=num;
temp2->next=NULL;
temp->next=temp2;
temp2->prev=temp;
}
}
void display()
{
struct node *r;
r=head;
while(r!=NULL)
{
printf("%d ",r->data);
r=r->next->next;
}
}
void main()
{
func(100);
func(200);
func(300);
func(400);
display();
}
Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
static int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
void func()
{
func1();
}
/* Test2.c */
#include "Test1.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
void main ()
{
func1();
func();
}
The operator used to get value at address stored in a pointer variable is :
< NIL>
Give the output of the following code snippet :
void func(int p[2][2],int row)
{
for(int i=0; i< row; i++)
{
for(int j=0; j< row; j++)
{
printf("%d ", p[i][j]);
}
}
}
int main()
{
int arry[2][2]= {1,2,3,4};
func(arry,2);
}
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 );
}
Give the output of the following code snippet :
void main()
{
int a=50,c=0,b=0;
_asm
{
mov eax,-10
mov ebx,a
sub eax,ebx
mov b,eax
add eax,a
and eax,c
jns Label1
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
void main()
{
int k = 2.5;
int *p = &k;
int **m = &p;
**m = 12;
printf("%d\n", *p);
}
Give the output of the following code snippet :
int main()
{
int a = 10;
_asm
{
mov a,100
mov eax,200
sub a,eax
}
printf("%d", a);
}
Give the output of the following code snippet :
void func(int arr[][5])
{
**arr++;
printf("%d ",**arr);
}
int main()
{
int arry[][5]= {1,2,3,4,5,6};
func(arry);
printf("%d ",**arry+3);
}
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;
}
Give the output of the following code snippet :
struct student
{
float b;
};
void main()
{
struct student s;
printf("%d", sizeof(struct student));
}
Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
void func1();
/* Test2.h */
static int value = 100;
void func();
/* Test1.c */
#include"Test2.h"
void func()
{
printf("Output = %d\n",value);
}
/* Test2.c */
#include"Test2.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
void main ()
{
func1();
func();
}
Give the output of the following code snippet :
int main()
{
int a[5][5] = {{1, 2, 3}, {1, 2, 3, 4}};
printf("%d",*a[2]+6);
}
Give the output of the following code snippet : Assume the array begins at the following address 5000.
int main()
{
float arr[3][2][2]= {20.75,10.5,5.25,0.0};
int s=sizeof(arr);
int s1=sizeof(arr[1][1]);
int s3=sizeof(arr[0]);
printf("%d %u %u",s+s1/s3,arr,&arr+1);
}
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 */
int value = 200;
void func()
{
int value = 200;
printf ( "Output = %d", value );
}
/* Test2.c */
#include"Test1.h"
void main ()
{
printf ( "Output = %d", value );
}
Give the output of the following code snippet :
int main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", *j*i);
return 0;
}
Give the output of the following code snippet :
int main()
{
int i = 3, a = 10, j = 5;
_asm
{
Label1: mov eax, dword ptr[a]
add eax, dword ptr[j]
add eax, dword ptr[i]
mov dword ptr[a], eax
mov ecx, dword ptr[i]
add ecx, 1
mov dword ptr[i], ecx
cmp dword ptr[i], 3
jl Label1
}
printf("%d", a);
}
Give the output of the following code snippet :
void main()
{
int a=20,c=-10,b=0;
_asm
{
mov eax,30
mov ebx,a
cmp eax,dword ptr[c]
jne Label2
mov b,eax
Label2:
mov ecx,c
cmp eax,ecx
js Label1
mov c,eax
}
Label1: printf("%d %d",b,c);
}
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(3,2);
printf("%s",str);
}
Give the output of the following code snippet :
void main()
{
int a=30,c=10,b=20;
_asm
{
mov eax,-30
mov ebx,dword ptr[b]
sub eax,ebx
jnge Label2
sub eax,10
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);
}
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!=0)
{
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,0));
}
Give the output of the following code snippet :
void main()
{
int a=100;
int b=200;
char str[10];
int x;
gcvt(25.3456,3,str);
printf("%s ",str);
}
Give the output of the following code snippet :
oid main()
{
int a = 10;
_asm
{
cmp dword ptr[a], 0Ah
jne Label1
mov dword ptr[a], 64h
jmp Label2
Label1: mov dword ptr[a], 14h
}
Label2:
printf("%d", a);
}
Give the output of the following code snippet :
int main()
{
struct stu
{
float sal:5;
char ch:4;
};
printf("%d", sizeof(struct stu));
return 0;
}
Give the output of the following code snippet :
struct p
{
int x;
char y;
struct p *ptr;
};
int main()
{
struct p t = {1, 2, t};
printf("%d\n", t.ptr->y);
return 0;
}
Give the output of the following code snippet :
typedef int(*fptr)(int a);
typedef struct
{
int a;
fptr fpt[100];
} fp;
int fun(int a)
{
_asm
{
mov dword ptr[a], 0C8h
}
printf("%d", a);
return 0;
}
int _tmain()
{
fp myS;
myS.fpt[0] = fun;
_asm
{
push 64h
mov edx, 4
imul eax, edx, 0
mov ecx, dword ptr[ebp + eax - 190h]
call ecx
add esp, 4
}
}
Give the output of the following code snippet :
void main()
{
char s1[]="Hello World";
int len=sizeof(s1);
memset(s1,'#',len-10);
puts(s1);
}
Give the output of the following code snippet :
void first()
{
printf("Hello World");
}
void main()
{
void (*ptr)();
ptr=&first;
ptr();
}
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);
}
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()
{
extern int value = 200;
printf ( "Output = %d", value );
value = 300;
}
/* Test2.c */
#include"Test1.h"
void main ()
{
printf ( "Output = %d\n", value );
func();
}
Give the output of the following code snippet :
struct student
{
char *name;
};
struct student s[2];
void main()
{
s[0].name = "Jenn";
s[1] = s[0];
printf("%s %s", s[0].name, s[1].name);
}
Give the output of the following code snippet :
struct student
{
char a[10];
};
void main()
{
struct student s[] = {"Hello", "World"};
printf("%d", sizeof(s));
}
Give the output of the following code snippet :
int DecToBin(int num)
{
if (num == 0)
{
return 0;
}
else
{
return (num % 2) + 10 * DecToBin(num / 2);
}
}
int main()
{
printf("%d",DecToBin(200));
}
Give the output of the following code snippet :
int main()
{
char *ptr;
ptr = (char*)malloc(30);
strcpy(ptr, "Hello");
printf("%s", ptr);
}
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("%.2f",fmod(z,y));
else
printf("%.2f",fmod(y,z));
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b = 0;
__asm
{
mov eax,Label1
call eax
mov ebx,Label2
jmp ebx
Label1 :
mov a, 100
ret
Label2 : mov b, 200
}
printf("%d %d", a,b);
}
Give the output of the following code snippet:
void main()
{
char *s = "hello";
char *p = s[3];
printf("%c\t%c", *p, s[1]);
}
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);
}
Give the output of the following code snippet :
#define PRINT printf("Hello World");
#define MAIN(PRINT) void main()\
{\
PRINT\
}
MAIN(PRINT)
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("%d",s->mark1);
}
What do the following lines of code indicate?
else
{
prev->next=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;
}
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);
}
Give the output of the following code snippet :
void *f()
{
int*p;
int x=100;
p=&x;
return p;
}
void main()
{
void *ptr;
ptr=f();
printf("%d",*(int*)ptr);
}
Give the output of the following code snippet :
struct stud
{
int age;
char *name;
}*stud;
void main()
{
printf("%d",sizeof(stud));
}
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);
}
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;
do
printf("%s ",argv[--argc]);
while(!argc);
}
Give the output of the following code snippet :
int main()
{
int a = 0;
int b = 0;
int c = 0;
int d=0;
_asm
{
mov eax, 10
push eax
mov ebx, 20
push ebx
mov ecx, 30
push ecx
mov edx, 40
push edx
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
mov ebx, dword ptr[esp-12]
mov c, ebx
add esp, 0x10
}
printf( "%d %d %d %d", a, b, c, d );
}
Give the importance of the following lines in the given code :
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;
}
Give the output of the following code snippet :
void main()
{
int (*a)[2] = {1, 2, 3, 0};
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
printf("%d ", **a);
}
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);
}
Give the output of the following code snippet :
void main()
{
double a=100.25;
double b=200.25;
double e = ((a) != (b) ? (a) : (b));
double c= abs(e);
printf("%.2f",c);
}
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);
}
int main(int argc, char *argv[])
{
print('X','Y');
}
Give the output of the following code snippet :
struct temp
{
int a;
int b;
int c;
} p[] = {10,20,,10};
void main()
{
printf("%d", sizeof(p));
}
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);
}
Give the output of the following code snippet :
int main()
{
int arry[10]= {1,2,3,4,5,6};
int x=arry[5];
x++;
int y=6[arry];
int z=x+y;
printf("%d",z);
}
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();
}
Give the output of the following code snippet :
int main()
{
int a = 10;
int b = 20;
int c = 30;
_asm
{
push eax
push a
push b
push 200
push 300
mov ebx, dword ptr[esp]
mov a, ebx
pop b
pop eax
mov ebx, dword ptr[esp+4]
mov b,ebx
add esp, 0x10
}
printf( "%d %d",a,b);
}
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[])
{
while(--argc>0)
printf("%s ", *++argv+1);
return 0;
}
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","r");
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);
}
Give the output of the following code snippet :
void main()
{
char a[10][6] = {"Hello","Jello","Yello"};
printf("%s ", a);
printf("%s", a[0]);
}
Give the output of the following code snippet :
void main()
{
int a = 1;
_asm
{
cmp dword ptr[a], 0
jne Label1
mov dword ptr[a], 64h
jmp Label2
Label1 : mov dword ptr[a], 0C8h
}
Label2: printf("%d", a);
}
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);
}
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]
sub ecx,10
dec 10
and ecx,ebx
mov c,ecx
}
printf("%d",c);
}
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;
if (ptr1 == *p1)
printf("%d\n", p1[4].x);
else
printf("%d\n", p1[2].y);
}
Give the output of the following code snippet :
int main()
{
int c=10;
_asm
{
mov eax,10
mov ebx,20
mult ebx
mov c, eax
}
printf("%d", c);
}
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]);
}
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));
}
Give the output of the following code snippet :
int x;
void fun(void *p)
{
int **q;
q = (int**)&p;
printf("%d ", **q);
}
void main()
{
void *ptr;
ptr = &x;
fun(ptr);
}
Give the output of the following code snippet :
void main()
{
int k,sum=0,prod=0,l=3;
_asm
{
mov dword ptr [k],0FFFFFFFDh
jmp Label1
Label4: mov eax,dword ptr [k]
add eax,1
mov dword ptr [k],eax
Label1 : cmp dword ptr [k],3
jge Label2
mov ecx,dword ptr [k]
imul ecx,dword ptr [l]
mov dword ptr [prod],ecx
cmp dword ptr [k],0
jne Label3
mov edx,dword ptr [prod]
add edx,dword ptr [l]
mov dword ptr [sum],edx
Label3 : jmp Label4
}
Label2 :
printf("%d %d",sum,prod);
}
Give the output of the following code snippet :
void main()
{
int a=20,c=10,b=30;
_asm
{
mov eax,30
mov ebx,a
xor eax,dword ptr[c]
jz Label2
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp eax,ecx
js Label1
and eax,dword ptr[b]
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
typedef void v;
v func(int*);
void main()
{
v *val;
int x=100;
val=&x;
func(val);
}
v func(void *x)
{
printf("%d",*(int*)x);
}
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)));
printf("%d",sizeof(*arr));
}
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);
}
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));
}
Give the output of the following code snippet :
int main()
{
int a = 20, b = 10,c=2;
_asm
{
mov eax,dword ptr[a]
mov ebx,dword ptr[b]
mov dword ptr[c],10
shl ecx,2
and ecx,ebx
mov dword ptr[a],ecx
}
printf("%d",a);
}
Give the output of the following code snippet :
void main()
{
int x=10,y=20;
int z=x+y;
int const* ptr=&z;
z++;
printf("%d",*ptr);
}
Give the output of the following code snippet :
int main()
{
int arry[10]= {1,2,3,4,5,6};
int x=arry[5];
x++;
int y=6[arry];
y++;
int z=x+y;
z++;
printf("%d",z);
}
Give the output of the following code snippet :
typedef struct student
{
char *a;
} stud;
void main()
{
stud s;
s.a = "Hello";
printf("%s", s.a);
}
Give the output of the following code snippet :
int print(int num,...)
{
int sum=0, count=0,i,j;
va_list marker;
va_start(marker,num);
for(i=0; i< num; i++)
{
j=va_arg(marker,int);
printf("%d ",j);
}
va_end(marker);
return sum;
}
int main(int argc, char *argv[])
{
print(3,4,6,-1);
}
Give the output of the following code snippet :
void main()
{
char *s= "hello";
char *p = s;
printf("%d %d", p[1], *s[1]);
}
What are pointers?
< NIL>
Give the output of the following code snippet :
void main()
{
char *str1="";
int n=printf("%s",str1);
if(n)
str1="New Program";
else
printf("Hello World");
}
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
sub eax,b
mov dword ptr[a],eax
}
printf("%d",a);
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b =0, c=0;
__asm
{
push 10
push 20
mov ebx,30
mov eax, 40
mov ecx,label1
call ecx
add esp, 8
mov ecx,Label2
jmp ecx
label1:
add esp,4
mov eax, dword ptr[esp + 8]
mov a, eax
pop eax
mov b, eax
mov eax, dword ptr[esp + 4]
mov c,ebx
sub esp,8
ret
}
Label2:
printf("%d %d %d", a, b, c);
}
Give the output of the following code snippet :
union student
{
int no;
float no1;
double no2;
};
void main()
{
union student s= {10};
printf("%d",s.no2);
}
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
}
}
Give the output of the following code snippet :
void main()
{
char str[12]="Hello world";
char *str1="Yellow World";
str1[5]='L';
printf("%s",str);
}
Give the output of the following code snippet :
int main()
{
int ary[2][3];
int j = 20;
*ary[0] = j;
printf("%d %d", *ary[0],sizeof(ary));
}
Give the output of the following code snippet :
int main()
{
char a[1][5] = {"Hola"};
printf("%s", a[0]);
return 0;
}
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);
}
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);
}
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);
}
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;
}
}
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);
}
Give the output of the following code snippet :
int main()
{
int i=10,*p;
p=&i;
(*p)++;
printf("%d",(*p)++);
}
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);
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 0Ah
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov eax, dword ptr[i]
imul eax, dword ptr[ecx]
mov ecx, dword ptr[j]
cdq
idiv dword ptr[ecx]
add eax, dword ptr[i]a
mov dword ptr[k], eax
}
printf("%d\n", k);
return 0;
}
Give the output of the following code snippet :
void f(char* i)
{
printf("%s\n", i);
}
void (*fptr)(char*) = f;
void main()
{
fptr("HelloWorld");
}
Give the output of the following code snippet :
int main()
{
int a = 20, b = 10,c=2;
_asm
{
mov eax,esp
push ebx
push edx
mov ecx,esp
sub eax,ecx
mov b,eax
pop ebx
pop edx
}
printf("%d",b);
}
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(25));
}
Give the output of the following code snippet :
void main()
{
int y,z;
int x=printf("%d HelloWorld\n");
printf("%d",x);
}
Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
static int value;
void func();
/* Test1.c */
#include "Test1.h"
void func()
{
value = 200;
}
/* Test2.c */
#include "Test1.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
void main ()
{
func1();
func();
}
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(110011);
}
Give the output of the following code snippet :
union u
{
union
{
unsigned char x : 2;
unsigned int y : 2;
} p;
int x;
};
int main()
{
union u u1 = {2};
printf("%d\n", u1.p.y);
}
Give the output of the following code snippet :
void main()
{
int a=10,b=20,c=30,d;
int x,y,z;
x=a & b;
y=a | b;
z=x | y & c;
printf("%d %d %d",x,y,z);
}
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[2]));
}
Give the output of the following code snippet :
int main()
{
int a=10, b=20, c;
c = (a == 100 && b > 30);
c= a++ + b++ + ++c;
printf("%d", c);
return 0;
}
Give the output of the following code snippet :
void print(...)
{
int i;
va_list marker;
va_start(marker,int);
do
{
i=va_arg(marker,int);
printf("%d ",i);
}
while(i!=6);
va_end(marker);
}
int main(int argc, char *argv[])
{
print("Test",2,4,'D',-1);
}
Give the output of the following code snippet :
void func(int *p,int row,int col)
{
for(int i=0; i< row; i++)
{
for(int j=0; j< col; j++)
{
printf("%d ", *(p+i*col+j));
}
}
}
int main()
{
int arry[2][2]= {1,2,3,4};
func((int*)arry,2,2);
}
Give the output of the following code snippet :
void main()
{
int a = 100;
_asm
{
jmp Label1
jmp Label1
mov eax, dword ptr[a]
add eax, 64h
mov dword ptr[a], eax
jmp Label1
jmp Label1
mov dword ptr[a], 0C8h
}
Label1: printf("%d", a);
}
Give the output of the following code snippet :
void print(char* first,...)
{
int sum=0, count=0,i;
int marker;
va_start(marker,first);
do
{
i=va_arg(marker,int);
printf("%d ",i);
}
while(i!=6);
va_end(marker);
}
int main(int argc, char *argv[])
{
print("Test",2,4.3,6.5,-1);
}
Give the output of the following code snippet :
int main()
{
float *Pa1,*Pa2,*Pa3;
float a1=10.25,b1=12.5;
Pa1=&a1;
Pa2=&b1;
*Pa3=*Pa1 % *Pa2;
printf("%f",*Pa3);
}
Give the output of the following code snippet :
void f(char *k)
{
k[2] = 'm';
printf("%s\n", k);
}
void main()
{
char s[] = "hello";
f(s);
}
Give the output of the following code snippet :
int main()
{
int ary[4] = {1, 2, 3, 4};
printf("%d\n", *(ary+2));
}
Give the output of the following code snippet :
void func(int *p)
{
printf("%d\n", *p);
}
int main()
{
int i = 10;
func(&(++i));
}
Give the output of the following code snippet :
void main()
{
static char *str=(char*)malloc(20);
str="Hello World";
printf("%s",str);
}
Give the output of the following code snippet :
void func(int x,int y)
{
int z=x>y;
int a=z< x;
int b=y>a;
printf("%d",b);
}
void main()
{
func(100,200);
}
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);
}
Give the output of the following code snippet :
int f(int i)
{
int sum=0;
_asm
{
mov dword ptr [sum],14h
mov eax,dword ptr [i]
add eax,0Ah
mov dword ptr [i],eax
imul ecx,dword ptr [sum],0Ah
mov dword ptr [sum],ecx
mov eax,dword ptr [i]
}
}
void main()
{
int a;
int(*fptr)(int) = f;
_asm
{
push 64h
call dword ptr [fptr]
add esp,4
mov dword ptr [a],eax
}
printf("%d", a);
}
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;
}
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
mov dword ptr[d],eax
call dword ptr[d]
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);
}
Give the output of the following code snippet :
struct student
{
char *name;
};
void func(struct student s)
{
struct student *s1;
s1=&s;
strcpy(s1->name,"Jenn");
printf("%s\t", s1->name);
}
void main()
{
struct student s;
func(s);
}
Give the output of the following code snippet :
struct temp
{
int a;
int b;
int c;
} p[5] = {10,20,3};
void main()
{
printf("%d", sizeof(p));
}
Give the output of the following code snippet :
struct node
{
int data;
struct node *next;
}*head=0;
void addtoLoc( int n,int num )
{
struct node *temp2,*temp;
temp2=head;
if(temp2==NULL)
{
printf("Empty List");
return;
}
for(int i=1; i< =n; i++)
temp2=temp2->next;
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=temp2->next;
temp2->next=temp;
}
void display(struct node *r)
{
r=head;
while(r!=NULL)
{
printf("%d ",r->data);
r=r->next;
}
}
void add( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=head;
head=temp;
}
void main()
{
struct node *n;
add(100);
add(200);
addtoLoc(0,400);
display(n);
}
Give the output of the following code snippet :
void main()
{
unsigned int a=10;
unsigned int b=10;
int c = a >> 2;
int d = b < < 2;
printf("%d %d",c,d);
}
Give the output of the following code snippet :
int main()
{
int y=100;
const int x=y++;
printf("%d\n", x);
return 0;
}
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 eax,ebx
mov a,eax
mov b,ebx
add esp, 12
jmp Label2
label1:
mov eax, dword ptr[esp + 4]
mov a, eax
add a, ebx
mov eax, dword ptr[esp + 8]
mov b, eax
mov eax, dword ptr[esp + 12]
or edx,ecx
mov c,eax
sub edx,ecx
sub edx,10
mov d,edx
ret
}
Label2:
printf("%d %d %d %d", a, b, c, d);
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b = 0, c=0,d=0;
__asm
{
push 10
push 20
push 30
push 40
mov ebx,30
mov eax, 40
mov ecx,label1
call ecx
add esp,0x10
mov edx,Label2
mov dword ptr[c],edx
jmp edx
label1:
add esp,4
pop eax
mov a, eax
pop eax
mov b, eax
pop eax
mov c,eax
mov eax, dword ptr[esp + 4]
mov d,eax
sub esp,16
ret
Label2:mov c,ebx
mov b,eax
}
printf("%d %d %d %d", a, b, c, d);
}