Knowledge check.
- Choose one best answer from given 4 choices for each questions.
- Review before submitting, as you won't get a chance to review after submitting.
- 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 :
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=20,b=40;
_asm
{
mov eax,20
mov ebx,a
sub eax,dword ptr[b]
jbe Label2
and eax,c
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp ecx,ebx
jns Label1
add eax,50
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
void f(int i)
{
printf("%d\n", i);
}
void (*fptr)(int) = f;
void main()
{
fptr("Hello");
}
Give the output of the following code snippet :
void main()
{
char *a[10] = {"Ha", "He", "Ho"};
int i = 0;
for (i = 0; i < 4; i++)
printf("%s ", a[i]);
}
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?40:100;
printf("%d %d %d",x,y,z);
return 0;
}
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 :
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
mov ebx, dword ptr[esp+4]
mov b, ebx
pop c
add esp, 0x10
}
printf( "%d %d %d",a,b,c);
}
Give the output of the following code snippet :
int main()
{
char ch = 'c';
char *chptr = &ch;
printf("%f",*chptr);
}
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 :
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 :
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 :
void main()
{
int x = 0;
int *const ptr = &x;
ptr++;
printf("%p\n ", ptr);
}
Give the output of the following code snippet :
void main()
{
char *str;
char *str2;
str="Hello";
str2="World";
strcat(str,str2);
printf("%s",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;
while(r!=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 :
void func(int p[][2],int row,int col)
{
for(int i=0; i< row; i++)
{
for(int j=0; j< col; j++)
{
printf("%d ", p[i][j]);
}
}
}
int main()
{
int arry[2][2]= {1,2,3,4};
func(arry,2,2);
}
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 :
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};
for (int i = 0; i < 2; i++)
for (int j = 0; j < 1; j++)
printf("%d ", *a[1]+1);
}
Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
void func1();
/* Test2.h */
static int value;
void func();
/* Test1.c */
#include"Test2.h"
void func1();
void func()
{
value = 200;
func1();
printf("Output = %d\n",++value);
}
/* Test2.c */
#include"Test2.h"
void func1()
{
value = 200;
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
void main ()
{
func();
}
Give the output of the following code snippet :
union Temp
{
int x;
char z;
};
void main()
{
union Temp t1;
t1.x=100;
t1.z='C';
printf("%d %c",t1.x,t1.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->next!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
AddNode(6);
AddNode(20);
AddNode(3);
AddNode(100);
AddNode(50);
SortList();
Display();
}
Give the output of the following code snippet :
void main()
{
char *a[10] = {"Yellow","Jello","Hello"};
printf("%d\n", sizeof(a));
}
Give the output of the following code snippet :
union u
{
struct p
{
unsigned char x : 2;
unsigned int y : 2;
};
int x;
};
int main()
{
union u u1;
u1.p.x = 2;
printf("%d\n", u1.p.x);
}
Give the output of the following code snippet :
int main()
{
int a=10, b=20, c,d;
c = (a == 10 && b > 30);
c= a++ + b++ + ++c;
d= ++a + ++b + --c;
printf("%d", d);
return 0;
}
Give the output of the following code snippet :
struct student
{
int mark1;
int mark2;
float val;
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 :
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 q
{
char *name;
struct q *next;
};
struct q *ptrary[10];
int main()
{
struct q *p;
p->name = "Hello";
ptrary[0] = p;
printf("%s\n", ptrary[0]->name);
return 0;
}
Give the output of the following code snippet :
int main()
{
int (*p)[5];
int a[][5]= {1,2,3,4,5,6};
p=a;
int *q[]= {*a,*a+1,*a+2};
printf("%d %d %d",**p+3,**q+2,**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]
add ecx,10
and ecx,ebx
xor ecx,ebx
mov dword ptr[c],ecx
}
printf("%d",c);
}
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 :
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 :
void main()
{
int a=30,c=-10,b=20;
_asm
{
mov eax,40
mov ebx,b
sub eax,dword ptr[b]
jo Label2
mov edx,dword ptr[c]
and edx,eax
mov b,edx
Label2:
mov ecx,dword ptr[a]
mov ebx,10
cmp ecx,ebx
je Label1
add eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
struct p1
{
unsigned int x : 4;
unsigned int y : 2;
};
int main()
{
struct p1 p;
p.x = 11;
p.y = 2;
printf("%d\n", p.x);
}
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);
}
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);
Display();
AddNode(6);
AddNode(20);
ReverseList();
Display();
}
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 :
struct Vehicle
{
int Id;
char *name;
struct Car
{
int Id;
char *name;
} Cobj;
};
void main()
{
struct Vehicle *Vobj;
Vobj->Cobj.Id=1001;
strcpy(Vobj->Cobj.name,"Nano");
printf("%s",Vobj->Cobj.name);
}
Which of the following is actually passed when an array name is passed as an argument to a function?
< NIL>
Give the output of the following code snippet :
int main()
{
int x=100,y=100;
int z = x++ || y++;
int a= --z || ++y && x--;
int b=a+(10,20,30,0);
printf("%d %d",b,a);
}
Give the output of the following code snippet :
int main()
{
int i=10,*p;
p=&i;
*p=*p+10;
printf("%d",*p);
}
Give the output of the following code snippet :
int **func()
{
int **p;
int *q;
int x=100;
p=&q;
q=&x;
return p;
}
void main()
{
int **(*f)();
f=func;
printf("%d",**f());
}
Give the output of the following code snippet :
int main()
{
int c=10;
_asm
{
mov c,100
add c,100
mov c, eax
}
printf("%d", c);
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 0Fh
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov edx, dword ptr[ecx]
add edx, 0Ah
mov eax, dword ptr[j]
mov dword ptr[eax], edx
mov ecx, dword ptr[j]
mov edx, dword ptr[i]
imul edx, dword ptr[ecx]
mov eax, dword ptr[j]
sub edx, dword ptr[eax]
mov dword ptr[k], edx
}
printf("%d\n", k);
}
Give the output of the following code snippet :
int main()
{
int i = 3, a = 10, j = 5;
_asm
{
Label3: cmp dword ptr[i], 0
je Label1
mov eax, dword ptr[a]
add eax, dword ptr[j]
mov dword ptr[a], eax
mov ecx, dword ptr[j]
add ecx, 1
mov dword ptr[j], ecx
mov edx, dword ptr[i]
sub edx, 1
mov dword ptr[i], edx
cmp dword ptr[i], 2
jne Label2
jmp Label1
Label2 : jmp Label3
}
Label1:
printf("%d", a);
}
Give the output of the following code snippet :
struct stu
{
char x : 2;
int y : 2;
};
int main()
{
struct stu p;
p.x = 2;
p.y = 1;
p.x = p.x & p.y;
printf("%d\n", p.x);
}
Give the output of the following code snippet :
int(*funcptr) (char a);
int myfunc(char a)
{
_asm
{
mov byte ptr [a],48h
mov al,byte ptr [a]
add al,3
mov byte ptr [a],al
}
printf("%d",a);
return 0;
}
int testCaller(int(*funcptr) (char a))
{
_asm
{
push 7Ah
call dword ptr [funcptr]
add esp,4
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
testCaller(myfunc);
return 0;
}
Give the output of the following code snippet :
struct temp
{
int a;
} s;
void change(struct temp s)
{
s.a = 1;
}
void main()
{
s.a = 10;
change(s);
printf("%d\n", s.a);
}
Give the output of the following code snippet :
int main()
{
int a = 10;
int b = 10;
if (a == (a|b) || a == (a&b))
printf("True ");
else
printf("False");
}
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 :
int main()
{
int*ptr;
int val=10;
ptr=&val;
printf("%d",*ptr);
}
Give the output of the following code snippet :
void main()
{
char str1[15]="Hello World";
char *str="Yellow";
str1[5]='\0';
printf("%s",str1);
}
In an array, a variable or expression of type array is the address of which element of the array?
< NIL>
Give the output of the following code snippet :
int main()
{
float x=10.00;
float y=10.001;
if( x == y)
printf("%.0f",x++ + ++y);
else
printf("%.0f",--y-++x);
}
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
}
printf("%d %d %d", a, b, c);
}
Give the output of the following code snippet :
int main()
{
int ary[4] = {1, 2, 3, 4};
int *p = ary + 3;
printf("%d\n", p[-1]);
}
Give the output of the following code snippet :
int main()
{
int ary[4] = {1, 2, 3, 4};
int p[4];
*p = ary[0];
printf("%d\n", p[0]);
}
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);
}
Give the output of the following code snippet :
void main()
{
int ch=0,sum=0,i;
int num=8;
for (i=0; i< 4; i++)
{
printf("%d",(num<< i & 1 << 3)? 1 : 0);
}
}
Give the output of the following code snippet :
int main()
{
char *str = "Hello";
char strc[] = "World";
strcpy(strc, str);
printf("%s\n", strc);
return 0;
}
Give the output of the following code snippet :
typedef struct Test
{
int x, y;
};
int main()
{
Test *k1;
Test k= {1,2};
k1=&k;
printf("%d\n", k1->y);
}
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][j]);
}
}
}
int main()
{
int arry[2][2]= {1,2,3,4};
func(arry,2,2);
}
Give the output of the following code snippet :
int DecimalToOctal(long quotient)
{
long remainder;
int octalNumber[100], i = 1, j;
while (quotient != 0)
{
octalNumber[i++] = quotient % 8;
quotient = quotient / 8;
}
for (j = i - 1; j > 0; j--)
printf("%d", octalNumber[j]);
return 0;
}
void main()
{
DecimalToOctal(800);
}
Give the output of the following code snippet :
int main()
{
typedef char char_arry[6];
char_arry arry= {10,20,30,'a','b','c'};
int i=0;
while(i!=6)
{
printf("%d ",*(arry+i)+2);
i+=2;
}
}
Give the output of the following code snippet :
void main()
{
unsigned int a=10;
unsigned int b=17;
int c = a ^ b;
int d = ~b + 1;
printf("%d %d",c,d);
}
Give the output of the following code snippet :
int main()
{
enum Days {SUN,MON,TUES,WED,THURS,FRI,SAT};
Days day;
printf("%d %d",sizeof(Days),WED + THURS);
}
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 :
void func(struct stud *stuobj);
struct stud
{
int no;
int no2;
};
void main()
{
struct stud *s=(stud*)malloc(sizeof(stud));
s->no=1001;
func(s);
}
void func(struct stud *stuobj)
{
struct stud *s;
s=stuobj;
printf("%d",s->no);
}
Give the output of the following code snippet :
int sum(char* first,...)
{
int sum=0, count=0,i;
va_list marker;
va_start(marker,first);
do
{
i=va_arg(marker,int);
printf("%d ",i);
}
while(i!=0);
va_end(marker);
return sum;
}
int main(int argc, char *argv[])
{
sum("Test",2,4,6,-1);
}
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
}
}
Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
extern int value;
void func();
/* Test1.c */
#include "Test1.h"
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 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 :
struct node
{
int x;
struct node *next;
}*Head;
void SortList()
{
node *temp1,*temp2,*temp3,*temp4,*temp5;
temp4=NULL;
while(temp4!=Head->next)
{
temp3=temp1=Head;
temp2=temp1->next;
while(temp1!=temp4)
{
if(temp1->x < temp2->x)
{
if(temp1==Head)
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
Head = temp2;
temp3=temp2;
}
else
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
temp3->next = temp2;
temp3=temp2;
}
}
else
{
temp3=temp1;
temp1=temp1->next;
}
temp2=temp1->next;
if(temp2 == temp4)
temp4=temp1;
}
}
}
void AddNode( int num )
{
struct node *temp,*temp2;
if(Head==NULL)
{
temp2=(struct node *)malloc(sizeof(struct node));
temp2->x=num;
temp2->next=NULL;
Head=temp2;
}
else
temp=Head;
while(temp->next!=NULL)
temp=temp->next;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->x=num;
temp2->next=NULL;
temp->next=temp2;
}
void Display()
{
struct node *r;
r=Head->next;
while(r!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
AddNode(6);
AddNode(20);
AddNode(3);
AddNode(100);
AddNode(50);
SortList();
Display();
}
Give the output of the following code snippet :
void main()
{
int a=-128,c=0,b=0;
_asm
{
mov eax,-150
sub eax,a
mov b,eax
add eax,a
js Label1
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
struct stu
{
char x ;
int y ;
};
int main()
{
struct stu p;
p.x = 2;
p.y = 1;
p.x = p.x || p.y;
printf("%d\n", p.x);
}
Which of the following statements is true about the array given below?
int *arry[13];
Give the output of the following code snippet :
struct student
{
char *c;
};
void main()
{
struct student m;
struct student *s = &m;
s.c = "SourceLens";
printf("%s", s.c);
}
Give the output of the following code snippet :
int(*funcptr) (int a);
int myfunc(int a)
{
int sum=0;
_asm
{
mov dword ptr [a],0Eh
mov eax,dword ptr [sum]
add eax,dword ptr [a]
mov dword ptr [sum],eax
mov ecx,dword ptr [a]
imul ecx
mov dword ptr [a],ecx
}
printf("%d",a);
return 0;
}
int testCaller(int(*funcptr) (int a))
{
_asm
{
push 32h
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, *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 ch=0,sum=0,i;
int num=3;
for (i=0; i< 4; i++)
{
printf("%d",(num<< i & 1 << 3)? 1 : 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 = 100;
void func();
/* Test1.c */
#include"Test2.h"
void func()
{
printf("Output = %d\n",value);
}
/* Test2.c */
#include"Test2.h"
int value = 200;
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
void main ()
{
func1();
func();
}
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 : 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 with the following command line arguments :
>Test.c Hello World Program
int main(int argc, char *argv[])
{
int i=strlen(argv[2]);
int sum=0;
while(i>=0)
{
printf("%c",argv[2][i]);
i--;
}
}
Give the output of the following code snippet :
int main()
{
int a=40, b=50, c,d;
c = (a == 10 && b > 30);
c= a++ / b-- + ++c;
d= ++a + ++b + --c;
printf("%d", d);
return 0;
}
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
push 200
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 d, ebx
add esp, 0x10
}
printf( "%d %d %d %d", a, b, c, d );
}
Give the output of the following code snippet :
void main()
{
unsigned int a=10;
unsigned int b=10;
int c = a^b;
int d = a&b;
printf("%d %d",c,d);
}
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=(stud *)malloc(sizeof(struct emp));
s->id=10;
printf("%d",s->id);
}
Give the output of the following code snippet :
void print(int num,int num2,...)
{
int i;
va_list marker;
va_start(marker,num2);
while((--num2) != 0)
{
i=va_arg(marker,int);
printf("%d ",i);
}
va_end(marker);
}
int main(int argc, char *argv[])
{
print(4,3,20,30);
}
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 ebx,a
js Label1
mov c,ebx
}
Label1: printf("%d %d",b,c);
}
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);
}
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 */
extern int value;
void func1();
/* Test2.h */
void func()
/* Test1.c */
#include "Test1.h"
int value = 100;
void func()
{
printf("Output = %d\n",value);
}
/* Test2.c */
#include "Test1.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
void main ()
{
func();
func();
}
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 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 :
int main()
{
typedef struct str *q;
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 :
void main()
{
enum days {MON,TUES,WED,THURS,FRI};
enum val;
for(int i=MON; i< FRI; i++)
{
printf("%d ",i);
}
}
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);
}
Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
static int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
void func()
{
value=200;
func1();
}
/* Test2.c */
#include "Test1.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
void main ()
{
func1();
func();
}
Which of the following are valid pointer operations in C?
< NIL>
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()
{
enum days {Mon=-1, Tue, Wed=-1, Thu, Fri, Sat,Sun};
printf("%d",Thu);
return 0;
}
Give the output of the following code snippet :
int main()
{
char *s;
char buf [] = "Hello World";
s = strrchr (buf, 'w');
if (s != NULL)
printf ("Found %s", s);
else
printf("Not found");
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 */
extern int value;
void func();
/* Test1.c */
int value = 100;
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 : 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 :
int main()
{
char *MemAlloc;
MemAlloc = (char*)malloc(20 * sizeof(char) );
strcpy( MemAlloc,"SourceLens");
printf("%s",MemAlloc);
}
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 = 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 :
int func()
{
int*p;
int x=88;
p=&x;
return *p;
}
void main()
{
void *ptr;
int (*f)();
f=func;
printf("%c",f());
}
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
mov eax, dword ptr[esp + 12]
mov b, eax
pop eax
mov c,eax
sub esp,8
ret
}
Label2:
printf("%d %d %d", a, b, c);
}
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 :
union Test
{
char str;
};
int main()
{
union Test st1, *st2;
st1.str='D';
st2 = &st1;
st1.str = 'J';
printf("%d",st2->str);
}
Give the output of the following code snippet :
int main()
{
struct u
{
unsigned char x : 1;
unsigned int y : 2;
float z :3;
} p;
struct u un;
un.z = 1.25;
printf("%f\n", un.f);
}
Consider the following code: Where are the elements added to in the list?
void func( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=head;
temp->prev=NULL;
while(head!=NULL)
head=head->next;
head=temp;
}
void main()
{
func(100);
func(200);
func(300);
func(400);
display();
}
Give the output of the following code snippet :
int main()
{
struct node
{
int data;
struct node *link;
};
struct node *p, *q;
printf("%d %d\n", sizeof(p), sizeof(q));
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 */
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"
int value = 300;
int arg;
void main ()
{
func(arg+value);
}
Give the output of the following code snippet :
void main()
{
char str[]="Hello world";
char *str1="Hello world";
if(strcmp(str,str1)==0)
printf("%s",str+2);
else
printf("%s",str1+5);
}
Give the output of the following code snippet :
#define row 3
#define col 3
void main()
{
int (*arr)[col];
arr=(int (*)[col])malloc(sizeof(row*sizeof(*arr)));
printf("%d",sizeof(arr));
free(arr);
}
Give the output of the following code snippet :
int main()
{
int c;
_asm
{
mov eax,100
add eax,dword ptr[c]
mov c, eax
}
printf("%d", c);
}
Give the output of the following code snippet :
int main()
{
union stu
{
int sal:2;
char ch:2;
};
printf("%d", sizeof(union stu));
return 0;
}
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 dword ptr[c]
mov ebx,Label2
mov ecx,100
mov edx,25
jmp ebx
Label1 :
mov a, 20
mov d, ecx
ret
Label2 : mov b,edx
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()
{
int a=10,c=10,b=10;
_asm
{
mov eax,30
mov ebx,c
sub eax,ebx
jna Label2
mov b,eax
Label2:
mov ecx,dword ptr[a]
sub ecx,ebx
jne Label1
and eax,50
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
void main()
{
int arry[10]= {0};
printf("%d",*(arry+5));
}
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()
{
int a[5] = {1,2};
printf("%d", *a[0]);
return 0;
}
Give the output of the following code snippet :
void main()
{
int a=100;
int b=200;
char str[10];
int x;
itoa(4,str,2);
printf("%s ",str);
}
Give the output of the following code snippet :
union p
{
int x;
char y;
};
int main()
{
union p p1[] = {1, 92, 3};
union p *ptr1 = p1;
int x = (sizeof(p1));
printf("%d\n", x);
}
Give the output of the following code snippet : Assume the input given is 100.
void main()
{
int i=3;
int x;
do
{
scanf("%d",&x);
ungetc(x,stdout);
printf("%d ",x);
ungetc(x,stdin);
i--;
}
while(i>3);
}
Give the output of the following code snippet :
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
struct student m;
s.c = m.c = "Hello";
m.point = &s;
(m.point)->c = "World";
printf("%s %s", s.c, m.c);
}
Give the output of the following code snippet :
void main()
{
int a=20,c=-10,b=0,d=30;
_asm
{
mov eax,20
mov ebx,c
cmp eax,dword ptr[a]
jne Label2
and eax,dword ptr[c]
mov b,eax
Label2:
mov ecx,c
mov eax,ecx
cmp eax,dword ptr[d]
js Label1
mov c,eax
}
Label1: printf("%d %d",b,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 */
extern int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
int value = 300;
void func()
{
value=200;
printf ( "Output = %d\n", ++value );
func1();
}
/* Test2.c */
#include "Test1.h"
int value = 300;
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
void main ()
{
func1();
func();
}
Give the output of the following code snippet :
struct student
{
int no;
char name[20];
}
int main()
{
struct student s;
s.no = 8;
printf("Hello");
}
Give the output of the following code snippet :
int(*funcptr) (int a);
int myfunc(int a)
{
int sum=0;
_asm
{
mov dword ptr [a],0Ch
mov eax,dword ptr [sum]
add eax,dword ptr [a]
mov dword ptr [sum],eax
mov ecx,dword ptr [a]
add ecx,1
mov dword ptr [a],ecx
}
printf("%d",a);
return 0;
}
int testCaller(int(*funcptr) (int a))
{
_asm
{
push 10h
call dword ptr [funcptr]
add esp,4
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
testCaller(myfunc);
return 0;
}
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();
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b =0, c=0;
__asm
{
push 10
push 20
push 30
push 40
mov ebx,30
mov eax, 40
mov ecx,label1
call ecx
add esp, 8
mov edx,Label2
mov dword ptr[c],edx
jmp dword ptr[c]
label1:
mov eax, dword ptr[esp + 4]
mov a, eax
mov eax, dword ptr[esp + 8]
mov b, eax
mov eax, dword ptr[esp + 12]
mov c,ebx
ret
Label2:mov c,ebx
mov b,200
}
printf("%d %d %d", a, b, c);
}
Give the output of the following code snippet :
int main()
{
char *a[1] = {"Hello"};
printf("%s", *a);
return 0;
}
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->x == p1[0].x)
printf("%d\n", p1[4].x);
else
printf("%d\n", p1[2].y);
}
Give the output of the following code snippet :
struct stud
{
int age;
char *name;
};
void func(struct stud *ob)
{
struct stud *pobj;
pobj=ob;
pobj->age=22;
printf("%d",pobj->age);
}
void main()
{
const struct stud s2= {20,"Jenn"};
func(&s2);
}
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 = 5;
_asm
{
mov eax, dword ptr[a]
mov dword ptr[ebp - 0D0h], eax
cmp dword ptr[ebp - 0D0h], 5
je Label1
cmp dword ptr[ebp - 0D0h], 0Ah
je Label2
jmp Label3
Label1 : mov dword ptr[a], 0Ah
Label2 : mov dword ptr[a], 64h
}
Label3: printf("%d", a);
}
Give the output of the following code snippet :
void fun(int *);
int main()
{
int i = 10, *p = &i;
fun(&i);
}
void fun(int *p)
{
printf("%f\n", *p);
}
Give the output of the following code snippet who's solution configuration has been set to the DEBUG mode :
int main()
{
int a = 200, b = 100, c = 2;
_asm
{
mov eax, esp
mov ebx, 10
push eax
push ebx
mov ecx, esp
mov ebx, dword ptr[b]
sub ecx, eax
mov a, ecx
mov b, ebx
pop edx
add esp,8
}
printf("%d %d", a, b);
}
Give the output of the following code snippet :
int(*funcptr) (int a);
int myfunc(int a)
{
int sum=0;
_asm
{
mov dword ptr [sum],3Ah
mov dword ptr [a],32h
mov eax,dword ptr [sum]
add eax,dword ptr [a]
mov dword ptr [sum],eax
mov dword ptr [a],eax
}
printf("%d",a);
return 0;
}
int testCaller(int(*funcptr) (int a))
{
_asm
{
push 32h
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 :
void main()
{
char c=48;
int mask=01,i;
int num=55,n=4,temp;
temp=num;
for(i=0; i< 3; i++)
{
printf("%c ",num|mask);
mask< < =1;
}
}
Give the output of the following code snippet :
struct node
{
int x;
struct node *next;
}*Head;
void SortList()
{
node *temp1,*temp2,*temp3,*temp4,*temp5;
temp4=NULL;
while(temp4!=Head->next)
{
temp3=temp1=Head;
temp2=temp1->next;
while(temp1!=temp4)
{
if(temp1->x > temp2->x)
{
if(temp1==Head)
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
Head = temp2;
temp3=temp2;
}
else
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
temp3->next = temp2;
temp3=temp2;
}
}
else
{
temp3=temp1;
temp1=temp1->next;
}
temp2=temp1->next;
if(temp2 == temp4)
temp4=temp1;
}
}
}
void AddNode( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->x=num;
temp->next=Head;
Head=temp;
}
void Display()
{
struct node *r;
r=Head;
while(r->next!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
AddNode(6);
AddNode(20);
AddNode(3);
Display();
SortList();
Display();
}
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[])
{
print(10,'X','Y');
print2(10,88,89);
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 0Fh
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov eax, dword ptr[i]
sub eax, dword ptr[ecx]
mov ecx, dword ptr[j]
cdq
imul dword ptr[ecx]
sub eax, dword ptr[i]
add eax, dword ptr[i]
mov dword ptr[k], eax
}
printf("%d\n", k);
return 0;
}
Give the output of the following code snippet :
int sum(int x,int y)
{
return x+y;
}
void main()
{
int (*fptr)(int a,int b);
fptr = sum();
printf("%d",(*fptr)(10,20));
}
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 :
int main()
{
char *MemAlloc;
MemAlloc = (char*)malloc(20 * sizeof(char) );
strcpy( MemAlloc,"SourceLens");
printf("%d",MemAlloc);
}
Give the output of the following code snippet :
struct p
{
int x;
int y;
};
int main()
{
struct p p1[] = {1, 2, 3, 4, 5, 6};
struct p *ptr1 = p1;
printf("%d %d\n", ++ptr1->x, ++(ptr1 + 2)->x);
}
Give the output of the following code snippet :
void f(float i)
{
printf("%d\n", i);
}
void (*fptr)(float) = f;
void main()
{
fptr(100);
}
Give the output of the following code snippet :
struct stud
{
int no;
int no2;
}
void main()
{
struct stud s;
s.no=1001;
printf("%s",s.no);
}
Give the output of the following code snippet :
int func(int x)
{
int *ptr;
x=200;
ptr=&x;
return *ptr;
}
void main()
{
int (*f[5])(int);
f[2]=func;
printf("%d",(f[2])(100));
}
Give the output of the following code snippet :
struct stud
{
int no;
int no2;
stud *link;
};
typedef struct stud *ptr;
void main()
{
stud s;
s.no=10;
printf("%d",s.no);
}
If pointers p and q point to members of the same array, then which of the following relations are legal?
< NIL>
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 with the following command line arguments :
>Test.c Hello World
int main(int argc, char *argv[])
{
int i=0;
while(i!=argc)
{
printf("%s ",strupr(argv[i]));
i++;
}
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 */
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();
value = 300;
printf ( "Output = %d\n", ++value );
}
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 :
typedef struct stud
{
int no;
int no2;
stud *link;
} stud;
void main()
{
stud s;
s.no=1001;
printf("%d",s.no);
}
Give the output of the following code snippet :
struct temp
{
int a;
int b;
int c;
} p[] = {10,20,30,10};
void main()
{
printf("%d", sizeof(p));
}
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 :
void main()
{
int a=20,c=10,b=30;
_asm
{
mov eax,2
mov ebx,a
and eax,ebx
jz Label2
mov b,eax
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 ary[4] = {1, 2, 3, 4};
int *p;
p = ary + 3;
*p = 5;
printf("%d\n", ary[4]);
}
Give the output of the following code snippet :
void main()
{
char str1[15]="Hello World";
char *str="Yellow";
char *str2="World";
char *str3;
str3=strcat(str,str2);
printf("%s",str3);
}
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:
void main()
{
char *s = "hello";
char *p = s[3];
printf("%c\t%c", *p, s[1]);
}
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 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 : 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 :
union point
{
int x;
int y;
};
int main()
{
union point p1= {1};
union point *ptr1 = &p1;
printf("%d %d",(ptr1)->x,ptr1->y);
}
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);
}
Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
static int value;
void func1();
/* Test2.h */
extern int value;
void func();
/* Test1.c */
#include "Test1.h"
void func()
{
printf("Output = %d\n",value);
}
/* Test2.c */
#include "Test1.h"
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
void main ()
{
func1();
func();
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 2Bh
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov eax, dword ptr[i]
sub eax, dword ptr[ecx]
sub ecx, dword ptr[i]
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 :
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 :
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 :
typedef struct Test
{
int x, y;
};
int main()
{
Test *k1;
Test k= {1,2};
k1=&k;
printf("%d\n", k1.y);
}
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);
}
Consider the following snippet : Where is the node 'temp' inserted?
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;
}
Give the output of the following code snippet :
int main()
{
int x=100,y=200,z=0;
x>300?y=20;
x< 300?x=40:z=100;
printf("%d %d %d",x,y,z);
return 0;
}
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 importance of the below statement in the given code :
else
{
temp3=temp1;
temp1=temp1->next;
}
void SortList()
{
node *temp1,*temp2,*temp3,*temp4,*temp5;
temp4=NULL;
while(temp4!=Head->next)
{
temp3=temp1=Head;
temp2=temp1->next;
while(temp1!=temp4)
{
if(temp1->x > temp2->x)
{
if(temp1==Head)
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
Head = temp2;
temp3=temp2;
}
else
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
temp3->next = temp2;
temp3=temp2;
}
}
else
{
temp3=temp1;
temp1=temp1->next;
}
temp2=temp1->next;
if(temp2 == temp4)
temp4=temp1;
}
}
}
Which of the following are illegal pointer operations in C?
< NIL>
Give the output of the following code snippet :
int main ()
{
char *ptr="Hello";
printf("%s",++ptr);
}
Give the output of the following code snippet :
struct p
{
int x;
char y;
struct p *ptr;
};
int main()
{
struct p t = {1, 2, 3, 4};
printf("%d\n", t.ptr->x);
return 0;
}
Give the output of the following code snippet :
void main()
{
int a=2,b=3,c=4;
unsigned int d=2;
int x=1,y=2,z=30;
x= a || b & c ;
y = x | 2 & b;
printf("%d %d %d",x,y,-2 < < ~2);
}
Give the output of the following code snippet :
struct student
{
int mark1;
char *name1;
};
void main()
{
struct student stud;
stud.mark1=100;
stud.name1="Jenn";
struct student *s=&stud;
printf("%s",s.name1);
}
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 :
int f(int i)
{
_asm
{
mov eax,dword ptr [i]
add eax,64h
add eax,0Fh
mov dword ptr [i],eax
mov eax,dword ptr [i]
}
}
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 :
struct q
{
char *name;
struct q *next;
};
struct q *ptrary[10];
int main()
{
struct q *p;
p->name = "Hello";
ptrary[0] = p;
printf("%s\n", ptrary[0].name);
return 0;
}
Give the output of the following code snippet :
int main()
{
int a,b=2,c=10;
_asm
{
mov dword ptr[a],0
mov dword ptr[b],20
add eax,dword ptr[c]
or ebx,eax
shr ebx,5
inc ebx
mov a,ebx
}
printf("%d",a);
}
Give the output of the following code snippet :
void main()
{
int arry[10]= {1,2,3,4};
printf("%p",arry);
}
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();
}
Consider the following snippet : Give the importance of the following lines :
for(int i=1;i<=n;i++)
{
temp2=temp2->next;
}
void addtoLoc( int n,int num )
{
struct node *temp2,*temp;
temp2=head;
if(temp2==NULL)
{
printf("Empty List");
return;
}
for(int i=1; i< =n; i++)
temp2=temp2->next;
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=temp2->next;
temp2->next=temp;
}
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 :
void main()
{
int a=30,c=20,b=50;
_asm
{
mov eax,10
mov ebx,dword ptr[b]
cmp eax,ebx
jle Label2
and eax,ebx
mov b,eax
Label2:
mov ecx,dword ptr[c]
sub ecx,ebx
jnz Label1
or eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
void main()
{
FILE *fp,*fp1;
char x;
fp = fopen("Test.txt","w+");
fputs("Hello", fp);
fclose(fp);
fp1 = fopen("Test.txt","r");
while(1)
{
x = fgetc(fp1);
if( feof(fp1) )
{
break;
}
printf("%c", x);
}
fclose(fp1);
}
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;
/* Test1.c */
void func()
{
int value = 200;
printf ( "Output = %d", value );
}
/* Test2.c */
#include"Test1.h"
int value = 100;
void main ()
{
printf ( "Output = %d", value );
}
Give the output of the following code snippet :
void main()
{
int a=20,c=10,b=30;
_asm
{
mov eax,10
mov ebx,a
sub eax,ebx
jb Label1
mov b,200
mov c,100
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
typedef struct
Student
{
int a;
} temp;
void main()
{
Student temp;
temp.a=100;
printf("%d",temp.a);
}
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 :
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 :
struct student
{
char *name;
};
struct student fun()
{
struct student s;
s.name = "Anne";
return s;
}
void main()
{
struct student m = fun();
printf("%s", m.name);
}
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 :
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 :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 20, b = 30, c=0,d=0;
__asm
{
push 10
push 20
push 30
mov ebx,a
push ebx
mov eax, 40
mov ecx,label1
call ecx
add esp,0x10
mov edx,Label2
mov dword ptr[c],edx
jmp dword ptr[c]
label1:
add esp,4
pop eax
mov a, eax
pop eax
mov b, eax
pop eax
mov c,eax
pop eax
mov d,eax
sub esp,20
ret
Label2:mov c,ebx
mov d,eax
}
printf("%d %d %d %d", a, b, c, d);
}
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 :
char *func(unsigned int num,int base)
{
static char bffer[33];
char *p=&bffer[sizeof(bffer)-1];
*p='\0';
do
{
*--p="0123456789"[num%base];
num/=base;
}
while(num!=0);
return p;
}
void main()
{
char *str;
str=func(9,8);
printf("%s",str);
}
Give the output of the following code snippet :
int main()
{
int i = 3, a = 10, j = 5;
_asm
{
Label2: cmp dword ptr[i], 5
jl Label1
jmp Label2
Label1 : mov eax, dword ptr[j]
imul eax, dword ptr[j]
add eax, dword ptr[a]
mov dword ptr[a], eax
mov ecx, dword ptr[a]
sub ecx, 1
mov dword ptr[a], ecx
mov edx, dword ptr[j]
add edx, 1
mov dword ptr[j], edx
mov eax, dword ptr[i]
add eax, 1
mov dword ptr[i], eax
}
printf("%d", a);
}
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 : Assume the input given is 100.
void main()
{
int i=3;
int x;
while(i!=0)
{
scanf("%d",&x);
printf("%d ",x);
ungetc(x,stdin);
i--;
}
}
Give the output of the following code snippet :
void main()
{
char arry[10]="Hello";
char str[15]="World";
char* ptr=str;
*arry='Y';
ptr=arry;
printf("%s",ptr);
}
Give the output of the following code snippet :
int main()
{
int a = 20, b = 10,c=2;
_asm
{
mov eax,esp
push ebx,10
mov ecx,esp
sub eax,ecx
mov b,eax
add esp,4
}
printf("%d",b);
}
Give the output of the following code snippet :
void main()
{
double a=100.25;
double b=200.25;
double c = ((a) = (b) ? (++a) : (--b));
double d= ((a) != (b) ? (a--) : (--b));
double e= (c < d) ? c : d;
printf("%.2f %.2f %.2f",c,d, e);
}
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!=NULL)
{
printf("%d ",r->data);
r=r->next->next;
}
}
void main()
{
func(100);
func(200);
func(300);
func(400);
display();
}
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 :
void main()
{
int a=20,c=10,b=30;
_asm
{
mov eax,20
mov ebx,a
cmp eax,dword ptr[c]
jnae Label2
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp eax,ecx
je Label1
or eax,30
mov c,eax
}
Label1: printf("%d %d",b,c);
}
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 p
{
char *name;
struct p *next;
};
struct p *ptrary[10];
int main()
{
struct p p;
p.name = "SourceLens";
p.next = NULL;
ptrary[0] = &p;
printf("%s\n", ptrary[0]->next);
return 0;
}
Give the output of the following code snippet :
void main()
{
int ch=0,sum=0;
for (int num=20; num > 0; num >>=2)
{
sum= num < < 1 & ~(3*1-4);
}
printf("%d",sum);
}
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 : Assume the contents of the file 'Test.txt' is
Hello World
void main()
{
char ch;
char str[10];
int count=0;
FILE *fp;
int i=0;
fp=fopen("Test.txt","r");
while((ch=getc(fp))!=EOF)
{
if(ch=='\n'|| ch==' ')
{
i++;
}
}
printf("%d",i);
fclose(fp);
}
Consider the given lines of code : When is the else{} part of the code executed?
void add( int num )
{
struct node *temp,*temp2;
if (head== NULL)
{
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=NULL;
head=temp;
}
else
{
temp=head;
while (temp->next!=NULL)
temp=temp->next;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->data=num;
temp2->next=NULL;
temp->next=temp2;
}
}
Give the output of the following code snippet :
int main()
{
char *a[2] = {"Hello"};
printf("%d", sizeof(a));
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
push 30
push 40
mov ebx,30
push ebx
mov eax, 40
mov ecx,label1
call ecx
add esp,0x10
mov edx,Label2
mov dword ptr[c],edx
jmp dword ptr[c]
label1:
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,eax
mov eax, dword ptr[esp + 16]
mov c,eax
ret
Label2:mov c,ebx
mov b,eax
}
printf("%d %d %d %d", a, b, c, d);
}
Give the output of the following code snippet :
void disp(int num,...);
int func();
void main()
{
int (*ptr)();
ptr=func;
disp("Test",ptr);
}
void disp(int num,...)
{
int (*pfun)();
va_list ptr;
typedef int(*funcptr)();
va_start(ptr,num);
pfun=va_arg(ptr,funcptr);
(*pfun)();
}
int func()
{
printf("Hello World");
return 0;
}
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 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 :
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 main()
{
int a = 15, b = 10, c=5;
_asm
{
mov eax,a
mov ebx,b
mov edx,dword ptr[c]
xor eax,ebx
and eax,edx
inc edx
mov dword ptr[a],eax
mov dword ptr[b],edx
}
printf("%d %d",a,b);
}
Give the output of the following code snippet :
union stud
{
int age;
char *name;
};
void main()
{
union stud s;
union stud *temp=(stud*)malloc(sizeof(stud));
temp->name="Jenn";
temp->age=22;
printf("%s",temp->name);
}
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);
}
Give the output of the following code snippet :
void main()
{
typedef char ptr,*qtr;
char fptr=100;
qtr a,b;
ptr p=20,q=30;
a=&fptr;
b=&p;
printf("%d %d",*a,*b);
}
Give the output of the following code snippet :
#define FUNC(a,b) (a*b+20);
#define PTR int*
void main()
{
int a=3,b=10;
PTR c,d;
d=FUNC(a,b);
c=&d;
printf("%d %d %d",a,b,*c);
}
Give the output of the following code snippet :
void print(int num,va_list marker);
void disp(int num,...)
{
va_list val;
va_start(val,num);
print(num,val);
}
void print(int num,va_list marker)
{
int i,k,j;
j=va_arg(marker,int);
printf("%d ",j);
va_end(marker);
}
int main(int argc, char *argv[])
{
disp(100,10,20,30);
}
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()
{
float arr[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",s+s1/s3);
}
Give the output of the following code snippet :
void main()
{
char a[10][6] = {"Hola","Hello","Jello"};
printf("%s", a);
}
Give the output of the following code snippet :
int func()
{
int **p;
int *q;
int x=100;
p=&q;
q=&x;
return **p;
}
void main()
{
int (*f)();
f=func;
printf("%d",f());
}
Give the output of the following code snippet :
int main()
{
enum Days {SUN,MON,TUES,WED,THURS,FRI,SAT};
Days day;
printf("%d",sizeof(day));
}
Give the output of the following code snippet : Assume the array begins at the following address 5000.
int main()
{
int (*p)[5];
int a[][5]= {1,2,3,4,5,6};
p=a;
printf("%u %u",p,a);
}
A pointer may be of the types :
< NIL>
Give the output of the following code snippet :
int main()
{
struct Temp
{
char one:1;
};
struct Temp var = {1};
printf("%c\n", var.one);
return 0;
}
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 ",(ptr1->y));
}
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 :
void func(int arr*[2][5])
{
**arr++;
printf("%d ",**arr);
}
int main()
{
int arry[2][5]= {1,2,3,4,5,6};
func(arry);
printf("%d ",**arry+3);
}
Give the output of the following code snippet :
void func(char *s)
{
printf("%s",s);;
}
void main()
{
char str[]="Hello World";
char *str1="Hello world";
str1="New Program";
func(str1);
}
Give the output of the following code snippet :
union stud
{
int age;
int id;
};
void main()
{
union stud s= {20,1001};
union stud *temp=(stud*)malloc(sizeof(stud));
temp=&s;
temp->id=30;
printf("%d",temp->age);
}
Give the output of the following code snippet :
struct node
{
int x;
struct node *next;
}*Head;
void ReverseList()
{
node *temp1,*temp2,*temp3;
temp1=Head;
temp2=NULL;
while(temp1!=NULL)
{
temp3=temp2;
temp2=temp1;
temp1=temp1->next;
temp2->next=temp3;
}
Head=temp2;
}
void AddNode( int num )
{
struct node *temp,*temp2;
if(Head==NULL)
{
temp2=(struct node *)malloc(sizeof(struct node));
temp2->x=num;
temp2->next=NULL;
Head=temp2;
}
else
temp=Head;
while(temp->next!=NULL)
temp=temp->next;
temp2=(struct node *)malloc(sizeof(struct node));
temp2->x=num;
temp2->next=NULL;
temp->next=temp2;
}
void Display()
{
struct node *r;
r=Head->next;
while(r!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
AddNode(6);
AddNode(100);
AddNode(200);
Display();
ReverseList();
Display();
}
Give the output of the following code snippet :
struct q
{
char *name;
struct q *next;
};
struct q *ptrary[10];
int main()
{
struct q *p;
p->name = "Hello";
ptrary[0] = p;
printf("%s\n", p->name);
return 0;
}
Give the output of the following code snippet : Assume the contents of the file 'Test.txt' is "Hello World".
void main()
{
char x;
FILE *fp;
fp=fopen("Test.txt","r");
while((x=getc(fp))!=EOF)
printf("%c",x);
printf("\n");
fclose(fp);
}
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 :
void main()
{
int a=10,b=20,c=30;
unsigned int d=12;
int x,y,z=40;
x=a && b || c;
y=x< < 2;
z>>=2;
printf("%d %d %d",x,y,~z);
}
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 main()
{
char a[1][5] = {"Hola"};
printf("%s", a[0]);
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);
}