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 :
union Test
{
char str[10];
char str2[20];
};
int main()
{
union Test st1, *st2;
strcpy(st1.str2,"Hello");
st2 = &st1;
printf("%s",st2->str);
}
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);
}
Give the output of the following code snippet :
typedef struct str *q;
int main()
{
struct str
{
int x;
char y;
q ptr;
};
struct str p = {10, 20, &p};
printf("%d\n", p.ptr->x);
return 0;
}
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 :
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
push 200
mov edx, 40
push edx
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
mov ebx, dword ptr[esp+12]
mov d, ebx
add esp, 0x10
}
printf( "%d",d);
}
Give the output of the following code snippet :
void main()
{
int a=20,c=0,b=0;
_asm
{
mov eax,-30
mov ebx,a
cmp eax,ebx
je Label2
mov b,eax
Label2:
mov c,ebx
}
printf("%d %d",b,c);
}
Give the output of the following code snippet :
int main()
{
int a=10, *j;
void *k;
j=k=&a;
j++;
k++;
printf("%u %u\n", *j,*k);
return 0;
}
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);
}
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);
}
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;
free(temp);
return 1;
}
}
else
{
prev=temp;
temp= temp->next;
}
}
return 0;
}
void main()
{
add(100);
add(200);
add(300);
Delete(100);
Delete(200);
display();
}
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);
}
Give the output of the following code snippet :
void main()
{
struct temp
{
int a;
struct temp1
{
float d;
} p;
};
struct temp st = {1,1.8};
printf("%d %f",st.a,p.d);
getch();
}
Give the output of the following code snippet :
int main ()
{
char *ptr="Hello";
printf("%d",strlen(ptr));
}
Give the output of the following code snippet :
void print(char* first,...)
{
int sum=0, count=0,i;
va_list 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,6,-1);
}
Give the output of the following code snippet :
void main()
{
int arry[10]= {1,2,3,4};
printf("%d",*arry+2);
}
Give the importance of the following line of code in the given function?
r=r->prev;
void func()
{
struct node *r;
r=head;
while(r->flink!=NULL)
r=r->flink;
while(r!=NULL)
{
printf("%d ",r->data);
r=r->blink;
}
}
The & operator cannot be used to applied to which of the following?
< NIL>
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);
}
Give the output of the following code snippet who's solution configuration has been set to the DEBUG mode :
int main()
{
int a = 20, b = 10, c = 2;
_asm
{
mov eax, esp
mov ebx, 100
push dword ptr[b]
mov ecx, esp
pop dword ptr[b]
mov ebx, dword ptr[b]
sub ecx, eax
mov a, ecx
mov b, ebx
pop edx
add esp,8
}
printf("%d %d", a, b);
}
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);
}
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 :
void main()
{
char s1[]="Hello";
char *s2;
int len=sizeof(s1);
s2=(char*)malloc(len);
memcpy(s2,s1,len);
puts(s2);
}
Give the output of the following code snippet :
int main()
{
int a = 10, b = 20,c=5;
_asm
{
mov eax,dword ptr[a]
mov ebx,dword ptr[b]
and ebx,100
mov c,eax
}
printf("%d",c);
}
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)
{
printf("%d ",r->data);
r=r->next;
}
printf("\n");
}
void main()
{
func(100);
func(200);
func(300);
func(400);
Delete(300);
Delete(400);
display();
}
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 :
void print(int num,...)
{
int i,k;
float j;
va_list marker;
va_start(marker,num);
j=va_arg(marker,float);
printf("%.2f ",j);
va_end(marker);
}
int main(int argc, char *argv[])
{
print(10,2,3.3,4.4);
}
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;
}
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);
}
}
Give the output of the following code snippet :
void convertToBinary(int val)
{
for (int c = 7; c >= 0; c--)
{
int k = val >> c;
if (k & 1)
printf("1");
else
printf("0");
}
}
int main()
{
convertToBinary(66);
}
Give the output of the following code snippet :
int func(int a,int b)
{
int x=a++;
int y=a---b++;
a>b?return(x:y);
}
int main()
{
int x=100,y=200;
int z = func(100,200);
printf("%d",z);
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 10
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov eax, dword ptr[i]
sub eax, dword ptr[ecx]
add ecx, dword ptr[i]
mov ecx, dword ptr[j]
cdq
imul dword ptr[ecx]
add eax, dword ptr[i]
mov dword ptr[k], eax
}
printf("%d\n", k);
return 0;
}
Give the output of the following code snippet :
char sub1()
{
return "HelloWorld";
}
void main()
{
char* (*fptr)();
fptr= &sub1;
printf("%s",(*fptr)());
}
Give the output of the following code snippet :
struct student
{
int mark1;
int mark2;
char name1;
char name2;
};
void main()
{
struct student stud;
struct student *s=&stud;
printf("%d",sizeof(stud));
}
Give the output of the following code snippet :
int main()
{
int i=10, *j;
j = &i;
*j+=1;
printf("%d ", *j**j+i**j);
return 0;
}
Give the output of the following code snippet :
void main()
{
char *s = "SourceLens";
char *p = s;
printf("%c %c", *p, s[1]);
}
Give the output of the following code snippet :
int func()
{
int **p;
int *q;
int x=100;
p=&q;
q=&x;
return x;
}
void main()
{
int (*f)();
f=func;
printf("%d",f());
}
Consider the following snippet: Where is the node temp2 added?
void add( int num )
{
struct node *temp,*temp2;
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;
}
Give the output of the following code snippet :
struct node
{
int x;
struct node *next;
}*Head;
void ReverseList()
{
node *temp1,*temp2,*temp3;
temp1=Head;
temp2=NULL;
while(temp1!=NULL)
{
temp3=temp2;
temp2=temp1;
temp1=temp1->next;
temp2->next=temp3;
}
Head=temp2;
}
void AddNode( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->x=num;
temp->next=Head;
Head=temp;
}
void Display()
{
struct node *r;
r=Head->next;
while(r->next!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
AddNode(6);
Display();
AddNode(20);
ReverseList();
Display();
}
Give the output of the following code snippet :
union point
{
int x;
int y;
};
int main()
{
union point p1[] = {1, 2, 3, 4, 5,6};
union point *ptr1 = p1;
printf("%d %d",(ptr1)->x,ptr1->y);
}
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);
}
Give the output of the following code snippet :
int main()
{
int a = 10, b = 5, c = 3;
b = ~a | ~c;
printf("%d", b);
}
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]
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);
}
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
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);
}
Give the output of the following code snippet :
void main()
{
int a=10,c=50,b=30;
_asm
{
mov eax,30
mov ebx,a
sub eax,dword ptr[b]
jc Label2
add eax,ebx
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp eax,ecx
jne Label1
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
int main()
{
int a = 20, b = 10,c=2;
_asm
{
mov eax,esp
mov ebx,100
push dword ptr[b]
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);
}
What do the following lines indicate in the given code?
temp2=head;
if(temp2==NULL)
{ return;
}
void addtoLoc( int n,char* num )
{
struct node *temp2,*temp;
temp2=head;
if(temp2==NULL)
{
return;
}
for(int i=0; i< n; i++)
temp2=temp2->next;
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=temp2->next;
temp2->next=temp;
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
};
struct point func(struct point);
int main()
{
struct point p1 = {1, 2};
p1.y=func(p1);
printf("%d\n", p1.y);
}
struct point func(struct point p)
{
p.y=20;
return p;
}
Give the output of the following code snippet :
void f(int i)
{
printf("%d\n", i);
}
void (*fptr)(float) = f;
void main()
{
fptr(100);
}
Give the output of the following code snippet :
int func()
{
int z=100;
if(!z)
return z++;
else
return --z;
}
int main()
{
const int x=func();
int y;
y=x+func();
int z=x+y;
printf("%d",z);
}
Give the output of the following code snippet :
int main()
{
float x=0.3,y=10,z=20;
if( x < 0.3)
printf("%lf",y+z);
else
printf("%lf",z-y);
}
Give the output of the following code snippet :
struct student
{
int age;
char name[25];
};
int main()
{
struct student c[] = { {12, "Jenn"},
{13, "Abby"}
};
printf("%d ", c.age);
return 0;
}
Give the output of the following code snippet : What are the contents of the file 'Test.txt' after the code is executed?
void main()
{
char x;
FILE *fp;
fp=fopen("Test.txt","w+");
fprintf("%s","Hello","World");
fclose(fp);
}
Give the output of the following code snippet :
int main()
{
int a = 10;
_asm
{
mov eax,100
mov ebx,200
sub eax,eax
mov a,eax
}
printf("%d", a);
}
Give the output of the following code snippet :
void main()
{
int row=2,col=2;
int **arr;
int i,j;
arr=(int**)malloc(row*sizeof(int));
for(i=0; i< row; i++)
arr[i]=(int*)malloc(col*sizeof(int));
for(i=0; i< row; i++)
{
for(j=0; j< col; j++)
{
arr[i][j]=i+j;
printf("%d ",arr[i][j]);
}
}
}
Give the output of the following code snippet :
int main()
{
int a = 1;
_asm
{
mov eax, dword ptr[a]
mov dword ptr[ebp - 0D0h], eax
cmp dword ptr[ebp - 0D0h], 0
je Label1
cmp dword ptr[ebp - 0D0h], 2
je Label2
cmp dword ptr[ebp - 0D0h], 3
je Label3
jmp Label4
Label1 : mov dword ptr[a], 2
Label2 : mov dword ptr[a], 3
jmp Label4
Label3 : mov eax, dword ptr[a]
add eax, 4
mov dword ptr[a], eax
}
Label4: printf("%d", a);
}
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 :
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++);
}
Give the output of the following code snippet :
void main()
{
int a = 50, b = 40, c = 20;
_asm
{
cmp dword ptr[a], 32h
jge Label1
mov eax, dword ptr[b]
add eax, dword ptr[c]
mov dword ptr[a], eax
jmp Label2
Label1 : mov eax, dword ptr[b]
sub eax, dword ptr[c]
mov dword ptr[a], eax
Label2 :
}
printf("%d %d %d", a, b, c);
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
};
void fun(struct point p[])
{
printf("%d %d\n", p[1].x,(p + 1)->y);
}
int main()
{
struct point p1[] = {1};
fun(p1);
}
Give the output of the following code snippet :
void main()
{
char *str;
char *str2;
str="Hello";
str2="World";
str=str2;
printf("%s",str);
}
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"
int value = 100;
void main ()
{
printf ( "Output = %d\n", value );
func();
}
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);
}
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);
}
Give the output of the following code snippet :
char *func()
{
char *s;
*s=(char*)malloc(20*sizeof(char));
strcpy(s,"Hello World");
return s;
}
void main()
{
char *s;
s=func();
printf("%s",s);
}
Give the output of the following code snippet :
void main()
{
int a[2][5] = {1, 2, 3, 0};
for (int i = 0; i < 1; i++)
for (int j = 0; j < 1; j++)
printf("%d ", *a[0]);
}
Give the output of the following code snippet :
void main()
{
int a=100;
int b=200;
char str[10],st[10];
int x;
gcvt(25.3456,2,str);
itoa(100,st,16);
printf("%s %s",str,st);
}
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 *j = (int*)malloc(sizeof(int));
*j = 10;
printf("%d %d",*j, sizeof(j));
}
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);
}
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);
}
Give the output of the following code snippet :
int(*funcptr) (int a);
int myfunc(int a)
{
int sum=0;
_asm
{
mov dword ptr [a],0Fh
mov eax,dword ptr [sum]
add eax,dword ptr [a]
mov dword ptr [sum],eax
mov ecx,dword ptr [a]
add ecx,0Ah
mov dword ptr [a],ecx
}
printf("%d",a);
return 0;
}
int testCaller(int(*funcptr) (int a))
{
_asm
{
push 10h
call dword ptr [funcptr]
add esp,4
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
testCaller(myfunc);
return 0;
}
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",st1.str);
}
Give the output of the following code snippet :
void main()
{
int x = 0;
int *ptr = &10;
printf("%p\n", ptr);
}
Give the output of the following code snippet :
struct student
{
char a[10];
};
void main()
{
struct student s[] = {"Hello", "World"};
printf("%c", s[1].a[2]);
}
Give the output of the following code snippet :
void func(int *val)
{
*val+=10;
}
void main()
{
int arry[10]= {1,2,3,4,5};
func(&arry[0]);
const char str[15]="Hello World";
arry[2]=10;
str[0]='Y';
printf("%d %s",arry[2]+arry[0],str);
}
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);
}
Give the output of the following code snippet :
struct stud
{
int age;
char *name;
};
void func(const struct stud *ob)
{
const struct stud *pobj;
pobj=ob;
printf("%d",pobj->age);
}
void main()
{
struct stud s2= {20,"Jenn"};
func(&s2);
}
Give the output of the following code snippet :
int(*funcptr) (char a);
int myfunc(char a)
{
_asm
{
mov dword ptr [a],42h
}
printf("%d",a);
return 0;
}
int testCaller(int(*funcptr) (char a))
{
_asm
{
push 74h
call dword ptr [funcptr]
add esp,4
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
testCaller(myfunc);
return 0;
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 0Bh
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov eax, dword ptr[i]
add eax, dword ptr[ecx]
add ecx, dword ptr[i]
mov ecx, dword ptr[j]
cdq
imul dword ptr[ecx]
add eax, dword ptr[i]
mov dword ptr[k], eax
}
printf("%d\n", k);
return 0;
}
Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
int value = 100;
void func();
/* Test1.c */
int value = 200;
void func()
{
extern int value;
printf ( "Output = %d", value );
}
/* Test2.c */
#include"Test1.h"
void main ()
{
printf ( "Output = %d\n", value );
func();
}
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;
static int arg;
void func(int);
/* Test1.c */
#include "Test1.h"
void func(int arg)
{
arg=10;
value=200;
printf ( "Output = %d\n", arg+value );
}
/* Test2.c */
#include "Test1.h"
void main ()
{
arg=20;
value = 300;
func(arg+value);
}
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 :
int main()
{
int x=10,y=10,z=20;
int a= --z || ++y && x--;
int c= ++x * --y;
int b=(20,10)+a+(10,20,10)+c;
printf("%d %d",b,c);
}
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);
}
Give the output of the following code snippet :
void print(int num,...)
{
int i,j,k;
va_list marker;
va_start(marker,num);
j=va_arg(marker,char);
printf("%c ",j);
va_end(marker);
}
void print2(int num,...)
{
int i,j,k;
va_list marker;
va_start(marker,num);
j=va_arg(marker,int);
printf("%d ",j);
va_end(marker);
}
int main(int argc, char *argv[])
{
print2(10,'X','Y');
print2(10,88,89);
}
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));
}
Give the output of the following code snippet :
int main()
{
int ary[2][2];
ary[][] = {1, 2, 3, 4};
printf("%d", ary[1][0]);
}
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[])
{
printf("%d %s", argc, argv[1]);
return 0;
}
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 :
union Test
{
char str[20];
};
int main()
{
union Test st1, st2;
strcpy(st1.str, "Hello");
st2 = st1;
st1.str[0] = 'J';
st2.str[0] = 'Y';
printf("%s",st2.str);
}
Give the output of the following code snippet :
struct node
{
int x;
struct node *next;
}*Head;
void ReverseList()
{
node *temp1,*temp2,*temp3;
temp1=Head;
temp2=NULL;
while(temp1!=NULL)
{
temp3=temp2;
temp2=temp1;
temp1=temp1->next;
temp2->next=temp3;
}
Head=temp2;
}
void AddNode( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->x=num;
temp->next=Head;
Head=temp;
}
void Display()
{
struct node *r;
r=Head->next;
while(r!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
Display();
AddNode(6);
AddNode(20);
ReverseList();
Display();
}
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",floor(y)+ceil(z));
else
printf("%.2f",ceil(y)+floor(z));
}
Give the output of the following code snippet :
int main()
{
int a = 10, b = 20,c=5;
_asm
{
mov eax,a
mov ebx,b
xor eax,dword ptr[c]
mov b,eax
}
printf("%d",b);
}
Give the importance of the following lines of code from the given function :
if (head== NULL)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=NULL;
temp->prev=NULL;
head=temp;
}
void func( int num )
{
struct node *temp,*temp2;
if (head== NULL)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=NULL;
temp->prev=NULL;
head=temp;
}
else
{
temp=head;
while (temp->next!=NULL)
temp=temp->next;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->data=num;
temp2->next=NULL;
temp->next=temp2;
temp2->prev=temp;
}
}
Give the output of the following code snippet :
void main()
{
char *a[10] = {"hi", "hello", "how"};
printf("%d\n", sizeof(a[1]));
}
Give the output of the following code snippet :
int main()
{
typedef int integer i = 10, *ptr;
integer j = i;
ptr = &j;
printf("%d\n", *ptr);
}
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[3]=func;
printf("%d",(*f[3])());
}
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 = 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);
}
Give the output of the following code snippet :
void main()
{
char s[15] = "SourceLens";
char *p = s;
printf("%c %c", *(p+1), s[10]);
}
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;
}
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();
}
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 */
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 a = 5, b = 10, c=5;
_asm
{
mov eax,a
mov ebx,b
mov edx,dword ptr[c]
shl eax,5
mov dword ptr[a],eax
}
printf("%d %d",a,b);
}
Give the output of the following code snippet :
int main()
{
int a=10, b=20, c,d,e;
c = (a == 100 && b >= 10);
c= a--*a++-b++/--b;
d=a++%b--/c++;
e=d++/c---a++/b;
printf("%d %d %d", c,d,e);
return 0;
}
Give the output of the following code snippet :
void main()
{
int a=10,c=-10,b=30;
_asm
{
mov eax,10
mov ebx,b
cmp 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 i, *p, q;
_asm
{
mov dword ptr[i], 0Ah
lea eax, [i]
mov dword ptr[p], eax
mov ecx, dword ptr[p]
mov edx, dword ptr[ecx]
sub edx, 10
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, 6
mov dword ptr[p], eax
}
printf("%d", q);
}
Give the output of the following code snippet :
void main()
{
int a[10] = {1};
printf("%d %d", sizeof(a),a);
};
Give the output of the following code snippet :
struct student
{
int mark1;
int mark2;
};
void main()
{
struct student stud= {100};
struct student *s=&stud;
printf("%d",*s);
}
Give the output of the following code snippet :
void main()
{
int a = 50, b = 40, c = 20;
_asm
{
cmp dword ptr[a], 0Ah
jl Label1
cmp dword ptr[a], 64h
jle Label2
Label1 : mov eax, dword ptr[b]
add eax, dword ptr[c]
mov dword ptr[a], eax
jmp Label3
Label2 : mov eax, dword ptr[b]
sub eax, dword ptr[c]
mov dword ptr[a], eax
}
Label3: printf("%d %d %d", a, b, c);
}
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--]);
}
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 :
int f()
{
int*p;
int x=100;
p=&x;
return *p;
}
void main()
{
int *ptr;
ptr=f();
printf("%d",*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].x);
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 1Ah
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov edx, dword ptr[ecx]
sub edx, 5
mov eax, dword ptr[j]
mov dword ptr[eax], edx
mov ecx, dword ptr[j]
mov edx, dword ptr[i]
mov eax, dword ptr[j]
add edx, dword ptr[eax]
mov dword ptr[k], edx
}
printf("%d\n", k);
}
Give the output of the following code snippet :
int main()
{
const int x;
int y;
x=200;
y=300;
int z=x+y;
printf("%d",z);
}
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();
}
Give the output of the following code snippet :
int func(int *x)
{
int *ptr;
int y=100;
ptr=x;
ptr=&y;
return *ptr;
}
void main()
{
int (*f[5])(int*);
int *a;
int b=200;
a=&b;
f[0]=func;
printf("%d",(*f)());
}
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 :
int main()
{
float x = 0.3;
int y=10;
if (x == 0.3)
printf("%d",y++);
else if (x == 0.3f)
printf("%d",++y);
else
printf("%d",--y);
}
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 :
struct student
{
char *name;
};
struct student s[2], *r[2];
void main()
{
s[0].name = "Jenn";
r[1] = &s[0];
printf("%s", r->name);
}
Give the output of the following code snippet :
struct node
{
int x;
struct node *next;
}*Head;
void SortList()
{
node *temp1,*temp2,*temp3,*temp4,*temp5;
temp4=NULL;
while(temp4!=Head->next)
{
temp3=temp1=Head;
temp2=temp1->next;
while(temp1!=temp4)
{
if(temp1->x < temp2->x)
{
if(temp1==Head)
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
Head = temp2;
temp3=temp2;
}
else
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
temp3->next = temp2;
temp3=temp2;
}
}
else
{
temp3=temp1;
temp1=temp1->next;
}
temp2=temp1->next;
if(temp2 == temp4)
temp4=temp1;
}
}
}
void AddNode( int num )
{
struct node *temp,*temp2;
if(Head==NULL)
{
temp2=(struct node *)malloc(sizeof(struct node));
temp2->x=num;
temp2->next=NULL;
Head=temp2;
}
else
temp=Head;
while(temp->next!=NULL)
temp=temp->next;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->x=num;
temp2->next=NULL;
temp->next=temp2;
}
void Display()
{
struct node *r;
r=Head;
while(r!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
AddNode(6);
SortList();
AddNode(20);
AddNode(3);
AddNode(100);
SortList();
Display();
}
Give the output of the following code snippet :
typedef void v;
v func(void*);
void main()
{
v *val;
int x=100;
val=&x;
func(val);
}
v func(void *x)
{
printf("%d",*x);
}
Give the output of the following code snippet :
void main()
{
int x = 1, y = 0, z = 5;
int a = x & y || z ^ y && x>>2;
printf("%d", a);
}
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();
}
Give the output of the following code snippet :
int main()
{
float x = 0.3;
if (x == 0.3)
printf("Hello");
else if (x == 0.3f)
printf("World");
else
printf("Program");
}
Give the output of the following code snippet :
int main()
{
int a = 20;
int b = 10;
int c=-(~(~a)+1);
printf("%d",c);
}
Give the output of the following code snippet : Assume the array begins at the following address 5000
int main()
{
int arr[5]= {20,10,5,0,1};
int arry2[]= {*arr,*arr+2,*arr+3,*arr+4};
printf("%u %u",arr+1,&arr+1);
}
Give the output of the following code snippet :
void main()
{
const char *str1="\n";
char str2[]="Hello World";
str1=str2;
printf("%s",str1);
}
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
push 200
push 300
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 with the following command line arguments :
>Test.c 100 200 300
int main(int argc, char *argv[])
{
for(int i=0; i< argc; i++)
printf("%s ", atoi(argv[i]));
return 0;
}
Give the output of the following code snippet :
int main()
{
int a,b,c=10;
_asm
{
mov dword ptr[a],15
mov dword ptr[b],20
add ebx,dword ptr[c]
mov eax,dword ptr[c]
or ebx,eax
shl ebx,2
mov a,ebx
}
printf("%d",a);
}
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,10
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 :
void main()
{
int a=10,b=20,c=30;
unsigned int d=12;
int x,y,z;
x=a && b && c;
y=a | b | c;
z=x && y | c;
printf("%d %d %d",x,~y,~d);
}
Give the output of the following code snippet :
int main()
{
int *p = (int *)10;
int *q = (int *)6;
printf("%d", p + q);
}
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]+1));
i++;
}
return 0;
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
};
void fun(struct point p[])
{
printf("%d %d\n", p->x, ++(p + 1)->y);
}
int main()
{
struct point p1[] = {1, 2, 3, 4, 5};
fun(p1);
}
Give the output of the following code snippet run with the following commandline arguments:
>Testfile.c one two
/* Testfile.c */
int main(int argc, char *argv[])
{
for(int i=1; i< argc; i++)
printf("%s ", *argv);
return 0;
}
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 :
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 :
int main()
{
int a,b,c=0;
_asm
{
mov dword ptr[a],100
mov dword ptr[b],10
and eax,ebx
or dword ptr[c],eax
mov dword ptr[c],eax
}
printf("%d",a);
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 5
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov edx, dword ptr[ecx]
sub edx, 0Ah
mov eax, dword ptr[j]
mov dword ptr[eax], edx
mov ecx, dword ptr[j]
mov edx, dword ptr[i]
imul edx, dword ptr[ecx]
mov eax, dword ptr[j]
add edx, dword ptr[eax]
mov dword ptr[k], edx
}
printf("%d\n", k);
}
Give the output of the following code snippet :
void main()
{
struct student
{
int age;
int id;
};
struct student s= {20,1001};
int ch;
char str[10];
FILE *fp,*fp1;
fp=fopen("Test.txt","r");
fwrite(&s,sizeof(s),1,fp);
fclose(fp);
fp1=fopen("Test.txt","r");
struct student s1;
fread(&s1, sizeof(s1), 1, fp1);
printf("%d",s1.age);
fclose(fp1);
}
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;
}
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);
return 0;
}
Give the output of the following code snippet :
struct student
{
int age;
char name[25];
};
int main()
{
struct student c[] = { {12, "Jenn"},
{13, "Abby"}
};
printf("%d ", c[].age);
return 0;
}
Give the output of the following code snippet :
int main()
{
int a = 20, b = 10,c=2;
_asm
{
mov eax,100
push eax
push ebx
mov ecx,esp
sub ebx,ecx
pop ebx
pop eax
mov a,eax
mov b,ecx
}
printf("%d %d",a,b);
}
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++);
}
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=x< < 3;
z>>=1;
printf("%d %d %d",x,y,~z);
}
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);
ungetc(x,stdin);
i--;
}
}
Give the output of the following code snippet :
struct stud
{
int age;
char *name;
};
const struct stud s;
void func(struct stud *ob)
{
struct stud *pobj;
pobj=ob;
printf("%d",pobj->age);
}
void main()
{
struct stud s2= {20,"Jenn"};
func(&s2);
}
Give the output of the following code snippet :
int main()
{
enum days {Mon=-1, Tue, Wed=6, Thu, Fri, Sat,Sun};
printf("%d",Mon);
return 0;
}
Give the output of the following code snippet :
struct
{
char *name;
union
{
char *sval;
} u;
} symtab[10];
void main()
{
symtab[0].u.sval="HelloWorld";
printf("%s",symtab[0].u.sval);
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
};
void fun(struct point *p)
{
p.x=10;
printf("%d\n", p.x);
}
int main()
{
struct point p1 = {1, 2};
fun(&p1);
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 10, b = 10,c=10,d=10;
__asm
{
mov eax,Label1
mov dword ptr[c],eax
call eax
mov ebx,Label2
mov ecx,100
jmp ebx
Label1 :
mov a, ecx
mov d, 50
ret
Label2 : mov b,100
mov c,300
}
printf("%d %d %d %d", a,b,c,d);
}
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 : Assume the contents of the file 'Test.txt' is "Hello World".
void main()
{
FILE *fp,*fp1;
char x[20];
fp = fopen("Test.txt","r");
int i=0;
while(fgets(x,8,fp)!=NULL)
{
puts(x);
}
fclose(fp);
}
Give the output of the following code snippet :
int main()
{
int a[2][2] = {1, 2, 3, 4};
int *ptr;
ptr = &a[0][0];
printf("%d\n", *ptr);
}
Give the output of the following code snippet :
void main()
{
int x=0,z;
float p=2.4567;
double q=5.6543;
float r=0.0;
printf("%.2f %.4lf",p+q-r,q);
}
Give the output of the following code snippet :
struct stud
{
int age;
char *name;
};
const struct stud s;
void func(struct stud ob)
{
struct stud pobj;
pobj=ob;
printf("%d",pobj.age);
}
void main()
{
struct stud s2= {20,"Jenn"};
func(&s2);
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
} p[] = {1, 2, 3, 4, 5};
void fun(struct point*);
int main()
{
fun(p);
}
void fun(struct point p[])
{
printf("%d %d\n", p++->x, ++p[2].y);
}
Give the output of the following code snippet :
struct student
{
char *name;
};
struct student s[2], *r[2];
void main()
{
s[0].name = "Jenn";
r[1] = &s[0];
printf("%s", r[1]->name);
}
Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
int value = 300;
void func();
/* Test1.c */
void func()
{
int value = 200;
printf ( "Output = %d", value );
}
/* Test2.c */
#include"Test1.h"
void main ()
{
func();
printf ( "Output = %d\n", value );
}
Give the output of the following code snippet :
int main()
{
struct Temp
{
char one:1;
};
struct Temp var = {1};
printf("%d\n", var.one);
return 0;
}
The & operator cannot be used to applied to which of the following?
< NIL>
Give the output of the following code snippet :
struct p
{
char *c;
struct p *next;
};
struct p *ptrary[10];
int main()
{
struct p p1;
printf("%d",sizeof(ptrary));
return 0;
}
Give the output of the following code snippet :
void main()
{
int a=20,c=10,b=30;
_asm
{
mov eax,2
mov ebx,a
cmp eax,dword ptr[c]
jnae Label2
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp eax,ecx
je Label1
and eax,30
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
struct Vehicle
{
int Id;
char *name;
struct Car
{
int Id;
char *name;
} Cobj;
};
void main()
{
struct Vehicle *Vobj;
Vobj.Cobj.Id=1001;
printf("%d",Vobj.Cobj.Id);
}
Give the output of the following code snippet :
void main()
{
int x=10,y=20;
int z=x+y;
const int* ptr=&z;
z++;
printf("%d",*ptr);
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
};
void fun(struct point p[])
{
printf("%d %d\n",p->y,++p[1].y);
}
int main()
{
struct point p1[] = {1, 2, 3, 4};
fun(p1);
}
Give the output of the following code snippet :
union Test
{
char str[10];
char str2[20];
};
int main()
{
union Test st1, st2;
strcpy(st2.str2, "Hello");
st1 = st2;
printf("%s",st1.str);
}
Give the output of the following code snippet :
char *func()
{
char *str=(char *)malloc(20);
strcpy(str,"Hello World");
return str;
}
void main()
{
char *s;
s=func();
printf("%s",s);
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 10h
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov eax, dword ptr[i]
add eax,12
mov ecx, dword ptr[j]
cdq
imul dword ptr[ecx]
sub eax, dword ptr[i]
mov dword ptr[k], eax
}
printf("%d\n", k);
return 0;
}
Give the output of the following code snippet :
int main()
{
float x=10.00;
float y=10.00;
if( x == y)
printf("%.0f",x++ +--y);
else
printf("%.0f",--y-++x);
}
Give the output of the following code snippet :
int main()
{
int a = 10;
_asm
{
mov a,100
mov a,200
mov a,eax
}
printf("%d", a);
}
Give the output of the following code snippet :
int main()
{
char *MemAlloc;
MemAlloc = (char*)malloc(20 * sizeof(char) );
strcpy( MemAlloc,"SourceLens");
printf("%s",MemAlloc);
}
Give the output of the following code snippet :
struct stud
{
int age;
char *name;
};
void main()
{
struct stud s;
struct stud *temp=(stud*)malloc(sizeof(stud));
temp->name=(char*)malloc(10);
temp->name="Jenn";
temp->age=22;
printf("%s",temp->name);
free(temp);
}
Give the output of the following code snippet :
void main()
{
char *str="Hello";
char *str2="World";
int x;
x=atoi(str)+atoi(str2);
printf("%d",x);
}
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);
}
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]);
}
Give the output of the following code snippet :
struct node
{
int data;
struct node *next;
}*head;
void func( int num )
{
struct node *temp2;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->data=num;
temp2->next=head;
head=temp2;
}
void display(struct node *r)
{
r=head;
while(r->next!=NULL)
{
printf("%d ",r->data);
r=r->next;
}
}
void main()
{
struct node *n;
func(100);
func(200);
func(300);
display(n);
}
Give the output of the following code snippet :
void func(char *s)
{
char *ptr;
ptr=s;
printf("%s",ptr);
}
void main()
{
char str[10];
func(str);
}
Give the output of the following code snippet :
struct student
{
int mark1;
int mark2;
};
void main()
{
struct student stud= {100,95};
int *s;
s=(int*)&stud;
printf("%d",*(s+2));
}
Give the output of the following code snippet :
void main()
{
struct temp
{
char c;
float d;
};
struct temp2
{
int a[3];
char b;
struct temp t1;
};
struct temp2 st = {{1,2,3},'P','q',1.4};
printf("%d %c %c %f",st.a[1],st.b,t1.c,t1.d);
getch();
}
Give the output of the following code snippet :
struct node
{
int data;
struct node *next;
struct node *prev;
}*head;
void func( int num )
{
struct node *temp,*temp2;
if (head== NULL)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=NULL;
temp->prev=NULL;
head=temp;
}
else
{
temp=head;
while (temp->next!=NULL)
temp=temp->next;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->data=num;
temp2->next=NULL;
temp->next=temp2;
temp2->prev=temp;
}
}
void displayrev()
{
struct node *r;
r=head;
while(r->next!=NULL)
r=r->next;
while(r!=NULL)
{
printf("%d ",r->data);
r=r->prev;
}
printf("\n");
}
void display()
{
struct node *r;
r=head->next;
while(r->next!=NULL)
{
printf("%d ",r->data);
r=r->next;
}
printf("\n");
}
void main()
{
func(100);
func(200);
func(300);
func(400);
display();
displayrev();
}
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 :
void main()
{
int a=40,c=50,b=30;
_asm
{
mov eax,10
mov ebx,dword ptr[b]
cmp eax,ebx
jge Label2
shr eax,1
or eax,dword ptr[a]
mov b,eax
Label2:
mov ecx,dword ptr[c]
sub ecx,ebx
js Label1
and eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
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();
}
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(1,400);
display(n);
}
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++;
printf("%d",*ptr);
}
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 :
int(*funcptr) (char a);
int myfunc(char a)
{
_asm
{
mov byte ptr [a],3Fh
mov al,byte ptr [a]
add al,6
mov byte ptr [a],al
}
printf("%c",a);
return 0;
}
int testCaller(int(*funcptr) (char a))
{
_asm
{
push 6Ch
call dword ptr [funcptr]
add esp,4
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
testCaller(myfunc);
return 0;
}
Give the output of the following code snippet :
struct node
{
char* data;
struct node *next;
}*head=0;
void add( char* num )
{
struct node *temp2;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->data=num;
temp2->next=head;
head=temp2;
}
void display(struct node *r)
{
r=head;
while(r->next!=NULL)
{
printf("%s ",r->data);
r=r->next;
}
}
void main()
{
struct node *n;
add("Hello");
add("World");
display(n);
}
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);
}
Give the output of the following code snippet :
struct student
{
char *name;
};
void fun()
{
struct student *s;
s->name = "Anne";
printf("%s", s->name);
}
void main()
{
fun();
}
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);
}
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)
{
sum=sum+atoi(argv[i]);
i++;
break;
}
printf("%d %d",argc,sum);
return 0;
}
Give the output of the following code snippet run with the following commandline arguments:
>Testfile.c one two three
/* Testfile.c */
int main(int argc, char **argv)
{
printf("%s\n", *++argv);
return 0;
}
Give the output of the following code snippet :
int main()
{
char *b = "Hello";
char *c = "World";
char *a[] = {b, c};
printf("%s", *a);
}
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]);
}
}
Give the output of the following code snippet :
void main()
{
int i = 0, a = 0;
_asm
{
Label2: cmp dword ptr[i], 0
je Label1
mov eax, dword ptr[a]
add eax, 1
mov dword ptr[a], eax
mov ecx, dword ptr[i]
add ecx, 1
mov dword ptr[i], ecx
jmp Label2
}
Label1:
printf("%d", a);
}
Give the output of the following code snippet :
int main()
{
int a = 20;
int b = 20;
if ((a < < 1) == (b * 2))
printf("True ");
else
printf("False");
}
Give the output of the following code snippet :
int main()
{
int *Pa1 = 0;
int *Pa2 = 0;
int *Pa3 = 0;
int c = 0;
int a, b;
_asm
{
mov dword ptr[a], 0Ah
mov dword ptr[b], 14h
lea eax, [a]
mov dword ptr[Pa1], eax
lea ecx, [b]
mov dword ptr[Pa2], ecx
mov edx, dword ptr[Pa1]
mov eax, dword ptr[edx]
mov ecx, dword ptr[Pa2]
add eax, dword ptr[ecx]
mov dword ptr[c], eax
lea edx, [c]
mov dword ptr[Pa3], edx
}
printf("%d", *Pa3);
}
Give the output of the following code snippet :
void main()
{
typedef unsigned int uint;
typedef float fl;
uint x=100,y=200;
fl p=100.25,q=200.50;
unsigned int a=300,b=400;
int z = x+y-a/b;
float w= q/p;
float v=z/w;
printf("%.2f",v);
}
Give the output of the following code snippet :
struct student
{
int age;
char name[25];
};
int main()
{
struct student c[] = { {12, "Jenn"},
{13, "Abby"}
};
printf("%s ", (*(c+1)).name);
return 0;
}
Give the output of the following code snippet :
float *func()
{
float *s;
s=(float*)calloc(1,sizeof(float));
*s=100.25;
return s;
}
void main()
{
float *s;
s=func();
printf("%.3f",*s);
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
};
int main()
{
struct point p = {1};
struct point p1 = {1};
if(p.y == p1.y)
printf("Equal\n");
else
printf("not equal\n");
}
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();
}
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 x=10,y=1;
int z=++x || y--;
if(z < x^y || y%x)
printf("%d",z++- ++x);
else
printf("%d",z--+ --y);
}
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};
(*q)++;
printf("%d %d %d",**q+4,**p+3,*(*(a+3)+2));
}
Give the output of the following code snippet :
int main()
{
int *p = (int *)2;
int *q = (int *)3;
printf("%d", p - q);
}
Give the output of the following code snippet :
struct p
{
unsigned int x : 2;
unsigned int y : 2;
};
int main()
{
struct p p;
p.x = 4;
p.y = 1;
printf("%d\n", p.x);
}
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;
void func(int);
/* Test1.c */
#include "Test1.h"
void func(int arg)
{
value=200;
printf ( "Output = %d\n", arg+value );
}
/* Test2.c */
#include "Test1.h"
static int arg=10;
void main ()
{
func(arg);
value = 300;
printf ( "Output = %d\n", ++value );
}
Give the output of the following code snippet :
struct student
{
char a[10];
};
void main()
{
struct student s[] = {"Hello"};
printf("%c", s[1].a[2]);
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b =0, c=0;
__asm
{
push 10
push 20
mov ebx,30
mov eax, 40
mov ecx,label1
call ecx
add esp, 8
mov ecx,Label2
jmp ecx
label1:
add esp,4
mov eax, dword ptr[esp + 4]
mov a, eax
pop eax
mov b, eax
mov eax, dword ptr[esp + 12]
mov c,ebx
sub esp,8
ret
}
Label2:
printf("%d %d %d", a, b, c);
}
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(6+"Hello World");
return 0;
}
Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
int value = 100;
void func();
/* Test1.c */
void func()
{
int value = 200;
printf ( "Output = %d", value );
}
/* Test2.c */
#include"Test1.h"
extern int value = 100;
void main ()
{
func();
printf ( "Output = %d\n", value );
}
Give the output of the following code snippet :
struct temp
{
int a;
int b;
int c;
} p[] = {10,20};
void main()
{
printf("%d", sizeof(p));
}
Give the output of the following code snippet :
int main()
{
float x=10.00;
double y=10.00;
if( x > y)
printf("%.2e %d",x,(int)x);
else
printf("%g %d",y,(int)y);
}
Give the output of the following code snippet :
int main()
{
float x = 0.3;
int y=10;
if (x == 0.3)
printf("%d",sizeof(x));
else if (x == 0.3f)
printf("%d",sizeof(0.3));
else
printf("%d",sizeof(0.3f));
}
Give the output of the following code snippet :
struct stud
{
int age;
char *name;
};
const struct stud s;
void func(struct stud *ob)
{
struct stud *pobj;
pobj=s;
printf("%d",pobj->age);
}
void main()
{
struct stud s2= {20,"Jenn"};
func(&s2);
}
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+TUES;
printf("%d",day);
}
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));
}
Give the output of the following code snippet :
int main()
{
char *Pa1;
char c = 'D';
_asm
{
lea eax, [c]
mov dword ptr[Pa1], eax
}
printf("%d", *Pa1);
}
Which of the following statements is true about an array of void data type?
< NIL>
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);
}
Give the output of the following code snippet :
struct
{
char *name;
union
{
char *sval;
} u;
} symtab;
void main()
{
symtab.u.sval="HelloWorld";
printf("%s",symtab.u.sval);
}
Which of the following operand can be applied to pointers p and q?Assuming initializations as
< NIL>
Give the output of the following code snippet :
Struct
{
char *name;
union
{
char *sval;
} u;
} symtab[10];
void main()
{
symtab[0].u.sval="HelloWorld";
printf("%c",symtab[0].u.sval[9]);
}
Give the output of the following code snippet :
int main()
{
int (*ptr);
int val=10;
ptr=&val;
printf("%d",*ptr);
}
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 :
void main()
{
char *s = "HelloWorld";
char *p = s * 3;
printf("%s %c", *p, s[1]);
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b =0, c=0,d=0;
__asm
{
push 10
push 20
push 30
mov ebx,50
mov eax, 40
mov ecx,60
call label1
add eax,ebx
mov a,eax
mov c,edx
add esp, 12
jmp Label2
label1:
mov eax, dword ptr[esp - 4]
mov a, eax
add a, ebx
mov eax, dword ptr[esp + 8]
mov b, eax
or b,ebx
mov eax, dword ptr[esp + 16]
or edx,ecx
mov c,eax
and edx,ecx
mov d,ebx
ret
}
Label2:
printf("%d %d %d %d", a, b, c, d);
}
Give the output of the following code snippet :
int main()
{
char ch = 'c';
char *chptr = &ch;
printf("%c",*chptr);
}
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()
{
int a=20,c=50,b=30;
_asm
{
mov eax,20
mov ebx,a
sub eax,dword ptr[c]
jc Label2
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp eax,ecx
jne Label1
or eax,30
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
void main()
{
char str[10]="Hello";
char *str2;
str2="World";
strcat(str,str2);
printf("%s ",str);
}
Give the output of the following code snippet :
struct Test
{
static int x: 2;
} t;
void main()
{
t.x=10;
printf("%d",t.x);
}
Give the output of the following code snippet :
int main()
{
int ***r, **q, *p, i=10;
p = &i;
q = &p;
r = &q;
printf("%d %d %d", *p, **q, ***r);
return 0;
}
Give the output of the following code snippet :
void main()
{
int a[3][3] = {2,4,5,6,7,8};
for (int i = 0; i < 1; i++)
for (int j = 0; j < 1; j++)
printf("%d ", *a[2]*3);
}
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 :
int func(int a,int b)
{
int x=a++*b++;
int y=a---b++;
return a>b?x++:--y;
}
int main()
{
int x=100,y=200;
int z = func(x,y);
printf("%d",z);
}
Give the output of the following code snippet :
int main()
{
int i=10,*p;
p=&i;
*p=(*p)++;
printf("%d",*p);
}
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"
void main ()
{
func(arg);
}
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 :
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);
}
Give the output of the following code snippet :
int main()
{
int *ptr1,*ptr2;
ptr1 = (int *)1000;
ptr2 = ptr1 >> 2;
return(0);
}
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 :
int main()
{
int a = 10, b = 20,c=5;
_asm
{
mov eax,dword ptr[a]
mov ebx,dword ptr[b]
mov ecx,10
and ecx,ebx
inc eax,1
mov dword ptr[c],ecx
}
printf("%d",c);
}
Which symbolic constant is often used in place of zero(0) to indicate it is a special value for pointer?
< NIL>
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 :
int main()
{
void *vp;
int j=65;
vp=&j;
printf("%c", *(int*)vp);
}
Give the output of the following code snippet :
struct node
{
int x;
struct node *next;
}*Head;
void ReverseList()
{
node *temp1,*temp2,*temp3;
temp1=Head;
temp2=NULL;
while(temp1!=NULL)
{
temp3=temp2;
temp2=temp1;
temp1=temp1->next;
temp2->next=temp3;
}
Head=temp2;
}
void AddNode( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->x=num;
temp->next=Head;
Head=temp;
}
void Display()
{
struct node *r;
r=Head->next;
while(r!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
AddNode(6);
Display();
AddNode(20);
ReverseList();
Display();
}