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 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 :
struct q
{
char *name;
};
struct q *ptrary[3];
int main()
{
struct q *p;
p->name = "Hello";
ptrary[0] = p;
p->name= "World";
ptrary[1] = p;
printf("%s\n", ptrary[1]->name);
return 0;
}
Give the output of the following code snippet :
void f(int i)
{
printf("%d\n", i);
}
void (*fptr)(int) = f;
void main()
{
fptr(10);
}
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 :
struct student
{
char *name;
};
void main()
{
struct student s, m;
s.name = "Abby";
m = &s;
printf("%s %s", s.name, m.name);
}
Give the output of the following code snippet :
void main()
{
int a=10,c=-10,b=10;
_asm
{
mov eax,10
mov ebx,b
sub eax,dword ptr[b]
jnle Label2
mov edx,dword ptr[c]
or edx,eax
mov b,edx
Label2:
mov ecx,dword ptr[a]
cmp ecx,ebx
jne Label1
add eax,ecx
or eax,edx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
struct node
{
int x;
struct node *next;
}*Head;
void ReverseList()
{
node *temp1,*temp2,*temp3;
temp1=Head;
temp2=NULL;
while(temp1!=NULL)
{
temp3=temp2;
temp2=temp1;
temp1=temp1->next;
temp2->next=temp3;
}
Head=temp2;
}
void AddNode( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->x=num;
temp->next=Head;
Head=temp;
}
void Display()
{
struct node *r;
r=Head->next;
while(r->next!=NULL)
{
printf("%d ",r->x);
r=r->next;
}
printf("\n");
}
int main()
{
AddNode(10);
AddNode(5);
AddNode(6);
AddNode(20);
Display();
ReverseList();
Display();
}
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 :
struct stud
{
int no;
int no2;
stud *link;
};
typedef struct stud *ptr;
void main()
{
stud s;
s.no=1001;
printf("%d",s.no);
}
Give the output of the following code snippet :
typedef struct stud
{
int no;
int no2;
stud *link;
} stud;
void main()
{
stud s;
s.no=10;
printf("%d",s.no);
}
Give the output of the following code snippet :
void main()
{
int k, sum = 0, prod = 0, l = 3;
_asm
{
mov dword ptr[k], 0FFFFFFFDh
jmp Label1
Label3 : mov eax, dword ptr[k]
add eax, 1
mov dword ptr[k], eax
Label1 : cmp dword ptr[k], 3
jge Label2
jmp Label2
jmp Label2
jmp Label3
}
Label2:printf("%d %d", sum, prod);
}
Give the output of the following code snippet :
void main()
{
char *a[10] = {"Hi", "Hello", "Hel"};
printf("%d\n", sizeof(a));
}
Give the output of the following code snippet :
int main()
{
double *ptr = (int *)100;
ptr = ptr + 2;
printf("%u", ptr);
}
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();
/* Test1.c */
#include "Test1.h"
void func()
{
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 _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
call label1
add eax,ebx
mov a,eax
mov ecx,25
add ecx,eax
mov c,ecx
add esp, 12
jmp Label2
label1:
mov eax, dword ptr[esp + 4]
mov a, eax
add a, ebx
mov eax, dword ptr[esp + 4]
mov b, eax
or b,ebx
mov eax, dword ptr[esp + 8]
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 : 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 :
int sum(int first,....)
{
int sum=0, count=0,i=first;
va_list marker;
va_start(marker,first);
while(i!=-1)
{
sum+=i;
count++;
i=va_arg(marker,int);
}
va_end(marker);
return sum;
}
int main(int argc, char *argv[])
{
printf("%d",sum(2,3,4,-1));
}
Give the output of the following code snippet :
int main()
{
int a = 10, b = 20, c;
_asm
{
mov eax,a
mov c,b
div ebx
mov dword ptr[a],ebx
mov dword ptr[b],eax
}
printf("%d %d",a,b);
}
Give the output of the following code snippet :
int main()
{
int i, *p, q;
_asm
{
mov dword ptr[i], 15
lea eax, [i]
mov dword ptr[p], eax
mov ecx, dword ptr[p]
mov edx, dword ptr[ecx]
add eax,edx
mov eax, dword ptr[p]
mov dword ptr[eax], edx
mov ecx, dword ptr[p]
mov edx, dword ptr[ecx]
add edx, dword ptr[i]
mov dword ptr[q], edx
mov eax, dword ptr[p]
add eax, 10
mov dword ptr[p], eax
}
printf("%d", q);
}
Give the output of the following code snippet :
int main()
{
float *p = (float *)0;
printf("%p ",p);
p=p+1;
printf("%p",p);
}
Give the output of the following code snippet :
int main()
{
int *ptr,qtr=0;
ptr=&qtr;
printf("%d",*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);
}
Give the output of the following code snippet :
void func(struct stud *stuobj);
struct stud
{
int no;
char name[3];
stud *link;
};
void main()
{
struct stud s= {1001,"Jenny"};
func(&s);
}
void func(struct stud *stuobj)
{
struct stud *s;
s=stuobj;
printf("%s",s->name);
}
Give the output of the following code snippet :
void func(int *p)
{
printf("%d\n", *p);
}
int main()
{
int i = 10;
func((&i)++);
}
Give the output of the following code snippet :
void main()
{
int a=2,c=10,b=30;
_asm
{
mov eax,1
mov ebx,a
sub eax,ebx
jb Label1
mov b,200
mov c,100
}
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 */
void func();
/* Test1.c */
#include "Test1.h"
void func()
{
printf ( "Output = %d\n", ++value );
}
/* Test2.c */
#include "Test1.h"
static int value;
void main ()
{
func();
printf ( "Output = %d\n", ++value );
}
Give the output of the following code snippet :
void m(int *p)
{
int i = 0;
for(i = 0; i < 5; i++)
printf("%d\t", p[i]);
}
void main()
{
int a[5] = {6, 5, 3};
m(a);
}
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 run with the following commandline arguments:
>Testfile.c one
/* Testfile.c */
int main(char *argv[])
{
while(--argc>0)
printf("%s ", *++argv+1);
return 0;
}
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 :
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 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()
{
int ch=0,sum=0,i;
int num=500,n=4,temp;
temp=num;
while(temp!=0)
{
temp>>=n;
ch++;
}
printf("%d",ch);
}
Give the output of the following code snippet :
int main()
{
int i, *p, q;
_asm
{
mov dword ptr[i], 0Fh
lea eax, [i]
mov dword ptr[p], eax
mov ecx, dword ptr[p]
mov edx, dword ptr[ecx]
sub edx, 0Ah
mov eax, dword ptr[p]
mov dword ptr[eax], edx
mov ecx, dword ptr[p]
mov edx, dword ptr[ecx]
mov dword ptr[q], edx
mov eax, dword ptr[p]
add eax, 10
mov dword ptr[p], eax
}
printf("%d", q);
}
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()
{
struct temp
{
int a;
char b;
struct temp1
{
float d;
} p;
};
struct temp st = {1,'A','i',1.8};
printf("%d %c %c %f",st.a,st.b,st.p.c,st.p.d);
getch();
}
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
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 :
struct point
{
int x;
int y;
int z;
};
int main()
{
int* offset=&(((point*)0)->z);
printf("%d",offset);
}
Give the output of the following code snippet :
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 :
void func(int *p)
{
printf("%d\n", *p);
}
int main()
{
int i = 10;
func(&(++i));
}
Give the output of the following code snippet :
void main()
{
int row=2,col=2;
int *arr;
int i,j;
arr=(int*)malloc(2*2*sizeof(int));
for(i=0; i< row; i++)
{
for(j=0; j< col; j++)
{
arr[i*col+j]=i*i;
printf("%d ",arr[i*col+j]);
}
}
}
Give the output of the following code snippet :
struct student
{
char *name;
};
void func(struct student s)
{
struct student *s1;
s1=&s;
strcpy(s1->name,"Jenn");
printf("%s\t", s1->name);
}
void main()
{
struct student s;
func(s);
}
Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
int value;
void func();
/* Test1.c */
extern int value;
void func()
{
printf ( "Output = %d", value );
}
/* Test2.c */
#include"Test1"
void main ()
{
printf ( "Output = %d\n", value );
func();
}
Give the output of the following code snippet :
void main()
{
char str1[12]="Hello world";
char *str="Yellow World";
char *x,*y;
strcpy(str1,str);
printf("%s",str1);
}
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 :
void main()
{
char *str[15]= {"This","is","a","Hello","World","Program"};
char *x;
x=str[4];
str[4]=str[5];
str[5]=x;
printf("%s",str[0]);
}
Give the output of the following code snippet :
void func(int p[],int count)
{
for(int i=0; i< count; i++)
printf("%d ", *p);
}
int main()
{
int arry[5]= {1,2,3,4,5};
func(arry,5);
}
A pointer may be of the types :
< NIL>
Give the output of the following code snippet who's solution configuration has been set to the DEBUG mode :
int main()
{
int a = 200, b = 100, c = 2;
_asm
{
mov eax, esp
mov ebx, 10
push eax
push ebx
mov ecx, esp
mov ebx, dword ptr[b]
sub ecx, eax
mov a, ecx
mov b, ebx
pop ebx
add esp,4
}
printf("%d %d", a, b);
}
Give the output of the following code snippet :
void main()
{
int 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]);
}
}
}
We can assign address of any data type to the void pointer.State true or false :
< 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,5,fp)!=NULL)
{
puts(x);
}
fclose(fp);
}
Give the output of the following code snippet :
int main()
{
int a = 10;
int b = 20;
int c = 30;
_asm
{
mov eax, 10
push eax
push a
push b
push c
mov ebx, dword ptr[esp]
mov a, ebx
pop b
pop c
add esp, 0x10
}
printf( "%d %d %d",a,b,c);
}
Give the output of the following code snippet :
int main()
{
int a = 10, b = 20, c;
_asm
{
mov eax, a
mov ebx, b
add eax, ebx
mov c, eax
}
printf("%x", c);
}
Consider a singly linked list with the elements 10,20,30,40 in that order. Predict the output of the following code :
typedef struct Node
{
int data;
struct Node *next;
} node;
void print(node *pointer)
{
printf("%d ",pointer->data);
print(pointer->next);
}
void main()
{
node *start,*temp;
start = (node *)malloc(sizeof(node));
temp = start;
temp -> next = NULL;
print(start->next);
}
Give the output of the following code snippet :
void f(int i)
{
printf("%d\n", i);
}
void (*fptr)() = f;
void main()
{
fptr(10);
}
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)
{
count++;
if(ch=='\n')
{
str[i]='\0';
strrev(str);
printf("%s %d",str,count);
i=0;
}
else
str[i++]=ch;
}
fclose(fp);
}
Predict the output of the following code snippet :
void func( 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;
temp2->prev=temp;
}
void main()
{
func(100);
func(200);
func(300);
func(400);
func(500);
display();
}
Give the output of the following code snippet :
typedef int(*fptr)(int a);
typedef struct
{
int a;
fptr fpt[10];
} fp;
int fun(int a)
{
int sum = 0;
_asm
{
mov eax, dword ptr[a]
add eax, 26h
mov dword ptr[a], eax
mov ecx, dword ptr[sum]
and ecx, dword ptr[a]
xor ecx,dword ptr[a]
mov dword ptr[sum], ecx
}
printf("%d", sum);
return 0;
}
int _tmain()
{
fp myS;
myS.fpt[1] = fun;
_asm
{
push 5Ah
mov ecx, 4
shl ecx, 0
mov edx, dword ptr[ebp + ecx - 28h]
call edx
add esp, 4
}
}
Give the output of the following code snippet :
int main()
{
int i = 3, a = 100, j = 5;
_asm
{
Label2: cmp dword ptr[i], 0
je Label1
mov eax, dword ptr[i]
sub eax, 1
mov dword ptr[i], eax
mov ecx, dword ptr[j]
add ecx, 1
mov dword ptr[j], ecx
mov edx, dword ptr[a]
add edx, dword ptr[j]
mov dword ptr[a], edx
jmp Label2
}
Label1:printf("%d %d", a, j);
}
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 :
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 importance of the following line in the given lines of code :
head=temp->next;
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;
}
The subscript for a two dimensional array can be written as?
< NIL>
Give the output of the following code snippet : Assume the input given is 100.25
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 :
struct stud
{
int age;
char *name;
};
void func(const struct stud *ob)
{
struct stud *pobj;
pobj=ob;
pobj->age=22;
printf("%d",pobj->age);
}
void main()
{
struct stud s2= {20,"Jenn"};
func(&s2);
}
Give the output of the following code snippet :
void f(int i)
{
printf("%d\n", i);
}
void (*fptr)(int) = f;
void main()
{
fptr("Hello");
}
Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
int value;
void func();
/* Test1.c */
extern int value;
void func()
{
printf ( "Output = %d", value );
}
/* Test2.c */
#include< Test1.h>
void main ()
{
printf ( "Output = %d\n", value );
func();
}
Give the output of the following code snippet :
int f(int i)
{
_asm
{
mov eax,dword ptr [i]
add eax,0Ah
mov dword ptr [i],eax
mov eax,dword ptr [i]
}
}
void main()
{
int a;
int(*fptr)(int) = f;
_asm
{
push 64h
call dword ptr [fptr]
add esp,4
mov dword ptr [a],eax
}
printf("%d", a);
}
Give the output of the following code snippet :
int main()
{
int y=100;
const int x=y++;
printf("%d\n", ++x);
return 0;
}
Give the output of the following code snippet :
void main()
{
int a=20,c=0,b=0;
_asm
{
mov eax,20
mov ebx,a
cmp eax,ebx
je Label2
mov b,eax
Label2:
and eax,ebx
mov c,eax
}
printf("%d %d",b,c);
}
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 :
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 :
typedef struct stud
{
int no;
int no2;
} stud;
void main()
{
stud s;
s.no=10;
printf("%d",s.no);
}
Give the output of the following code snippet :
struct point
{
int x;
int y;
};
void fun(struct point*);
int main()
{
struct point p1[] = {1, 2, 3, 4};
fun(p1);
}
void fun(struct point p[])
{
printf("%d\n", p.x);
}
Give the output of the following code snippet :
int main()
{
int a = 20, b = 10,c=2;
_asm
{
mov eax,esp
push ebx
mov ecx,esp
sub ecx,eax
mov b,ecx
pop ebx
}
printf("%d",b);
}
Files Test1.c, Test1.h, Test2.c and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
extern int value;
void func();
void func1();
/* Test1.c */
#include "Test1.h"
int value = 300;
void func()
{
value=200;
printf ( "Output = %d\n", ++value );
func1();
}
/* Test2.c */
#include "Test1.h"
void func1()
{
value=200;
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test1.h"
void main ()
{
func1();
}
Give the output of the following code snippet :
union p
{
int x;
char y;
};
int main()
{
union p p1[] = {1, 92, 3, 96};
union p *ptr1 = p1;
printf("%d\n",ptr1->y);
}
Give the output of the following code snippet :
void main()
{
char *s = "Hello";
char *p = s;
printf("%c\t%c", *p, s[3]);
}
Give the output of the following code snippet :
typedef void v;
v func(int,int);
void main()
{
v val=100;
int x=(int)val;
func(x,10);
}
v func(int x,int y)
{
printf("%d",x+y);
}
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 main()
{
char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
printf("%c", *argv[5]+1);
}
Predict the output of the following code snippet :
struct node
{
int data;
struct node *next;
}*head;
void add( int num )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
if (head== NULL)
{
head=temp;
head->next=NULL;
}
else
{
temp->next=head;
head=temp;
}
}
void display()
{
struct node *r;
r=head;
while(r!=NULL)
{
printf("%d ",r->data);
r=r->next->next;
}
}
void main()
{
add(100);
add(200);
add(300);
add(400);
display();
}
Give the output of the following code snippet :
int main()
{
int arr[5]= {20,10,5,0};
int arry2[]= {*arr,*arr+2,*arr+3,*arr+5};
int *p;
p=arry2;
++(*arry2);
++p;
arr[1]=10;
arry2[2]=++(*arr);
printf("%d %d",++*p,(*arr)+++(*arry2));
}
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)(a));
}
Give the output of the following code snippet : Assume the contents of the file 'Test.txt' is "Hello World".
void main()
{
char x;
int count=0;
FILE *fp,*fp1;
fp=fopen("Test.txt","w");
fseek(fp,10,SEEK_SET);
fputc('S',fp);
fclose(fp);
fp1=fopen("Test.txt","r");
while((x=getc(fp1))!=EOF)
{
printf("%c",x);
count++;
}
printf(" %d",count);
fclose(fp1);
}
Give the output of the following code snippet :
void main()
{
int a=20,c=20,b=10;
_asm
{
mov eax,10
mov ebx,dword ptr[c]
cmp eax,ebx
jnbe Label2
shl eax,1
or 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 : Assume address of p is 5000
int main()
{
double *p;
printf("%p ",p);
p=p+1;
printf("%p",p);
}
Give the output of the following code snippet :
int main()
{
char *p=0;
printf("%d",p);
}
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;
}
Give the output of the following code snippet :
struct q
{
char *name;
};
struct q *ptrary[3];
int main()
{
struct q *p;
p->name = "World";
ptrary[0] = p;
p->name= "Hello";
ptrary[1] = p;
printf("%s\n",ptrary[0]->name);
return 0;
}
Give the output of the following code snippet whose solution configuration has been set to the DEBUG mode :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
__asm
{
push 10
push 20
push 30
push 40
call Func
jmp End
Func :
add esp, 4
pop eax
mov a, eax
pop eax
mov b, eax
pop eax
mov c, eax
add eax,c
or eax,b
xor eax,a
mov d,eax
sub esp, 0x10
ret
End : add esp, 0xC
}
printf("%d %d %d %d", a, b, c, d);
}
Give the output of the following code snippet :
int main()
{
int a,b=2,c=10;
_asm
{
mov dword ptr[a],0
mov ecx,dword ptr[b]
mov dword ptr[b],20
add ecx,dword ptr[c]
or ecx,dword ptr[b]
dec ecx
mov a,ecx
}
printf("%d",c);
}
Give the output of the following code snippet :
int main()
{
float x=0.3,y=10.89,z=20.68;
if( x == 0.3)
printf("%.0f",fmod(z,y));
else
printf("%.0f",fmod(y,z));
}
Give the output of the following code snippet :
int main()
{
int arry[10]= {1,2,3,4,5,6};
int x=arry[5];
x++;
int y=6[arry];
y++;
int z=x+y;
z++;
printf("%d",z);
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
__asm
{
push 100
push 200
push 300
call Func
jmp End
Func :
add esp, 4
pop eax
mov a, eax
pop eax
mov b, eax
pop eax
mov c, eax
add eax,ebx
mov d,eax
sub esp, 0x10
ret
End : add esp, 0xC
}
printf("%d %d %d %d", a, b, c, d);
}
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));
}
Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
void func1();
/* Test2.h */
static int value;
void func();
/* Test1.c */
#include"Test2.h"
void func()
{
printf("Output = %d\n",value);
}
/* Test2.c */
#include"Test2.h"
void func1()
{
printf ( "Output = %d\n", ++value );
func();
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
int value = 200;
void main ()
{
func();
}
Give the output of the following code snippet :
void main()
{
int a=40,c=20,b=20;
_asm
{
mov eax,20
mov ebx,dword ptr[a]
cmp eax,ebx
jng Label2
mov edx,b
xor edx,eax
and eax,edx
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp ecx,ebx
jne Label1
add eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
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()
{
int a[2][2] = {2,4,5,6,7,8};
for (int i = 0; i < 1; i++)
for (int j = 0; j < 1; j++)
printf("%d ", *a[1]+2);
}
Give the output of the following code snippet :
int main()
{
int x=20,y=10,z=20;
int a= x=10 && z==30;
int b= x&y;
int c= x-- > y++;
printf("%d %d %d",a,b,c);
}
Give the output of the following code snippet :
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 :
struct point
{
int x;
float y;
};
void fun(struct point*);
int main()
{
struct point p1[] = {1, 2, 3, 4, 5};
fun(p1);
}
void fun(struct point p[])
{
printf("%d %f\n", p->x, p[3].y);
}
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 :
int main()
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
_asm
{
mov eax, 10
push eax
push 100
push 200
push 300
push 400
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",b);
}
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 :
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 :
int main()
{
int c=10;
_asm
{
mov eax,10
div dword ptr[c]
mov c, eax
}
printf("%d", c);
}
Give the output of the following code snippet :
void f(int a[][2])
{
a[1][1] = 3;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
printf("%d ", a[i][j]);
}
void main()
{
int a[2][2]= {};
f(a);
}
Give the output of the following code snippet :
void main()
{
char str1[15]="Hello World";
char str[10]="Yellow";
char str2[10]="\0World";
strcat(str,str2);
printf("%d %c",strlen(str1),"HelloWorld"[5]);
}
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();
}
Which of the following are illegal pointer operations in C?
< NIL>
Give the output of the following code snippet :
int main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", i+*j);
return 0;
}
Give the output of the following code snippet:
int main()
{
char *arg[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
printf("%c", **arg);
}
Give the output of the following code snippet :
int main()
{
int arry[10]= {1,2,3,4,5,6};
int x=arry[5];
x++;
int y=6[arry];
y--;
int z=x+y;
z--;
printf("%d",++z);
}
Give the output of the following code snippet :
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 :
int main()
{
int a = 10, b = 5, c = 3;
b = ~a;
c = ~(~a);
printf("%d %d", b, c);
}
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 importance of the following line of code in the given program :
temp2->next=temp3;
void ReverseList()
{
node *temp1,*temp2,*temp3;
temp1=Head;
temp2=NULL;
while(temp1!=NULL)
{
temp3=temp2;
temp2=temp1;
temp1=temp1->next;
temp2->next=temp3;
}
Head=temp2;
}
Give the output of the following code snippet :
int main()
{
int *ptr1, qtr = 0;
_asm
{
lea eax, [qtr]
mov dword ptr[ptr1], eax
}
printf("%d", *ptr1);
}
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 :
void fun(int *p)
{
int j = 5;
p = &j;
printf("%d ", *p);
}
int main()
{
int i = 100, *p = &i;
fun(&i);
printf("%d ", *p);
}
Give the output of the following code snippet :
#include< stdio.h>
int main()
{
#define VAR 10
typedef int iptr;
static iptr *ptr,*qtr;
int *rptr;
int x=VAR;
int y=200;
ptr=&x;
qtr=&y;
printf("%d",(*ptr)+(*qtr));
}
Give the output of the following code snippet :
int main()
{
int i=3, *j;
j = &i;
printf("%d\n", i**j);
return 0;
}
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 :
int sum(char* first,...)
{
int sum=0, count=0,i=0;
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("Test",2,4,6,-1);
}
Give the output of the following code snippet :
void main()
{
int a = 10;
int b = 20;
int c = 30;
int d = 0;
__asm
{
mov eax,c
push eax
mov eax,b
push eax
mov eax,a
push eax
push 200
push 300
mov eax,Func
mov dword ptr[d],eax
call dword ptr[d]
mov ebx,End
mov dword ptr[d],ebx
jmp dword ptr[d]
Func :
add esp,4
pop eax
mov a, eax
pop eax
mov b, eax
pop eax
mov d,eax
sub esp,0x10
ret
End : add esp, 0x10
}
printf("%d %d %d", a, b,c);
}
Files Test1.c, Test1.h, Test2.c, Test2.h and Test3.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
void func1();
/* Test2.h */
extern int value;
void func();
/* Test1.c */
#include"Test2.h"
void func()
{
printf("Output = %d\n",value);
}
/* Test2.c */
#include"Test2.h"
int value = 200;
void func1()
{
printf ( "Output = %d\n", ++value );
}
/* Test3.c */
#include "Test2.h"
void main ()
{
func1();
func();
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
__asm
{
push 100
push 200
call Func
jmp End
Func :
pop dword ptr[esp]
mov eax, dword ptr[esp]
mov a, eax
pop dword ptr[esp+8]
mov eax, dword ptr[esp + 8]
mov a, eax
ret
End :
}
printf("%d %d %d %d", a, b, c, d);
}
Give the output of the following code snippet :
int func()
{
int **p;
int *q;
int x=100;
p=&q;
q=&x;
return *q;
}
void main()
{
int (*f)();
f=func;
printf("%d",f());
}
Give the output of the following code snippet :
char *func()
{
char *str;
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 a[4] = {1, 2, 3, 4};
int *ptr = &a[2];
*ptr = *ptr * 1;
printf("%d\n", *ptr);
}
Give the output of the following code snippet :
int main()
{
union stud
{
int id;
char name[2];
};
union stud stu1 = {512};
union stud stu2 = {0, 2};
printf("%c",stu2.name[0]);
}
Give the output of the following code snippet :
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
printf("%d", sizeof(s));
}
Give the output of the following code snippet :
void main()
{
int x=10,y=20,arr[3],i;
for(i=0; i< 3; i++)
{
arr[i]=y+++(++x);
printf("%d ",arr[i]+x++);
}
}
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 :
void main()
{
int a=60,c=50,b=10;
_asm
{
mov eax,50
mov ebx,dword ptr[c]
sub eax,ebx
ja Label2
add eax,c
and eax,dword ptr[a]
mov b,eax
Label2:
mov ecx,dword ptr[b]
sub ecx,ebx
je Label1
and eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
int(*funcptr) (char a);
int myfunc(char a)
{
_asm
{
mov byte ptr [a],42h
mov al,byte ptr [a]
add al,5
mov byte ptr [a],al
}
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 a = 10, b = 20,c=5;
_asm
{
mov eax,a
mov ebx,b
or ebx,c
mov ecx,eax
xor ecx,ebx
mov c,ecx
}
printf("%d",c);
}
Give the output of the following code snippet with the following command line arguments :
>Testfile.c one two
/* Testfile.c */
int main(int argc, char *argv[])
{
int i=0;
while(argc!=0)
{
printf("%s ", *(argv+i));
i++;
argc--;
}
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;
/* 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 );
}
Which of the following statements is true about an array of void data type?
< NIL>
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 ecx,dword ptr[c]
sub eax,ebx
push eax
push ebx
xor ebx,ecx
inc ebx
pop ebx
pop eax
mov a,eax
mov b,ebx
}
printf("%d %d",a,b);
}
Give the output of the following code snippet :
void main()
{
int i = 10, k = 10, j = 2;
int *ary[2];
ary[0] = i;
ary[1] = j;
printf("%d\n", *ary[0]);
}
Give the output of the following code snippet :
oid main()
{
int a = 10;
_asm
{
cmp dword ptr[a], 0Ah
jne Label1
mov dword ptr[a], 64h
jmp Label2
Label1: mov dword ptr[a], 14h
}
Label2:
printf("%d", a);
}
Give the output of the following code snippet :
void main()
{
char str[]="Hello world";
char *str1="Hello world";
int n=strcmp(str,str1);
if(n)
printf("True");
else
printf("False");
}
Give the output of the following code snippet :
int main()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 20h
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov eax, dword ptr[i]
sub eax, dword ptr[ecx]
add eax,12
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 :
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 :
void main()
{
char arry[10]="Hello";
char str[15]="World";
char* const ptr=str;
*str='Y';
ptr=arry;
printf("%s",ptr);
}
Give the output of the following code snippet :
void main()
{
int a = 10;
int b = 20;
int c = 30;
int d = 0;
__asm
{
mov eax,c
push eax
mov eax,b
push eax
mov eax,a
push eax
mov eax,Func
call eax
mov ebx,End
jmp ebx
Func :
add esp,4
pop eax
mov a, eax
pop eax
mov b, eax
pop eax
mov c,eax
sub esp,0x10
ret
End : add esp, 0x10
}
printf("%d %d %d", a, b,c);
}
Give the output of the following code snippet :
char *func(unsigned int num,int base)
{
static char bffer[33];
char *p=&bffer[sizeof(bffer)-1];
*p='\0';
do
{
*--p="0123456789"[num%base];
num/=base;
}
while(num!=0);
return p;
}
void main()
{
char *str;
str=func(3,2);
printf("%s",str);
}
Give the output of the following code snippet :
void main()
{
char *s = "Ho";
char *p = s;
printf("%s\t%s", p, s);
}
Give the output of the following code snippet :
typedef struct stud
{
int no;
int no2;
studobj *link;
} studobj;
void main()
{
studobj s=(studobj *)malloc(sizeof(struct studobj));
s->no=10;
printf("%d",s->no);
}
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 :
int main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", *j*i);
return 0;
}
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);
}
Files Test1.c, Test1.h, Test2.c are in same directory with the content given below. All files are in the same project of a console application. Predict the output of the program.
/* Test1.h */
int value;
void func();
/* Test1.c */
extern int value;
void func()
{
printf ( "Output = %d", value );
}
/* Test2.c */
#include"Test1.h"
void main ()
{
printf ( "Output = %d\n", value );
func();
}
Give the output of the following code snippet : What are the contents of the file 'Test.txt' after the code is executed?
void main()
{
char x;
FILE *fp;
fp=fopen("Test.txt","w+");
fprintf(fp,"%s","Hello","World");
fclose(fp);
}
Give the output of the following code snippet :
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 : 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 :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b =0, c=0,d=0;
__asm
{
push 10
push 20
mov ebx,30
mov eax, 40
mov ecx,60
push 50
push 70
push 80
call label1
add eax,ebx
mov a,eax
mov b,ebx
add esp, 20
jmp Label2
label1:
mov eax, dword ptr[esp + 8]
mov a, eax
add a, ebx
mov eax, dword ptr[esp + 12]
mov b, eax
mov eax, dword ptr[esp + 16]
or edx,ecx
mov c,eax
sub edx,ecx
sub edx,10
mov d,edx
ret
}
Label2:
printf("%d %d %d %d", a, b, c, d);
}
Give the output of the following code snippet :
void main()
{
int a=20,c=10,b=0;
_asm
{
mov eax,-20
mov ebx,a
add eax,dword ptr[c]
jz Label2
mov b,eax
Label2:
mov ecx,c
cmp eax,ecx
js Label1
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
struct temp
{
int a;
int b;
int c;
} p[5] = {10,20,3};
void main()
{
printf("%d", sizeof(p));
}
Give the output of the following code snippet :
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);
}
Give the output of the following code snippet :
int main()
{
int* ptr;
int val=10;
ptr=&val;
printf("%d",*ptr);
}
Consider the given code given below : What do the nodes temp1 and temp2 point to?
temp2=temp1->next;
void SortList()
{
node *temp1,*temp2,*temp3,*temp4,*temp5;
temp4=NULL;
while(temp4!=Head->next)
{
temp3=temp1=Head;
temp2=temp1->next;
while(temp1!=temp4)
{
if(temp1->x > temp2->x)
{
if(temp1==Head)
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
Head = temp2;
temp3=temp2;
}
else
{
temp5=temp2->next;
temp2 -> next=temp1;
temp1->next=temp5;
temp3->next = temp2;
temp3=temp2;
}
}
else
{
temp3=temp1;
temp1=temp1->next;
}
temp2=temp1->next;
if(temp2 == temp4)
temp4=temp1;
}
}
}
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 :
union student
{
int rollno;
char *name;
};
int main()
{
union student stud, studt;
stud.name = "Jenn";
studt.rollno = 101;
printf("%s\n", stud.name);
}
Give the output of the following code snippet :
struct
{
int s[5];
union
{
float y;
char z;
} u;
} t;
void main()
{
printf("%d",sizeof(t));
}
Give the output of the following code snippet :
int main()
{
char str[] = "Hello";
char *s = str;
printf("%s\n", s+0);
return 0;
}
Give the output of the following code snippet :
void main()
{
double a=100.25;
double b=200.25;
double e = ((a) > (b) ? (a) : (b));
printf("%d",(int)e);
}
Give the output of the following code snippet :
int print(int num,...)
{
int sum=0, count=0,i,j;
va_list marker;
va_start(marker,num);
for(i=0; i< num+1; i++)
{
j=va_arg(marker,int);
printf("%d ",j);
}
va_end(marker);
return sum;
}
int main(int argc, char *argv[])
{
print(3,4,6,-1);
}
Give the output of the following code snippet :
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 = 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 run with the following commandline arguments:
>Testfile.c 1 2
/* Testfile.c */
int main(int argc, char *argv[])
{
int j;
j = argv[1] + argv[2];
printf("%d", j);
return 0;
}
Give the output of the following code snippet :
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 :
nt _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b = 0;
__asm
{
call Label2
mov a, 100
call Label3
mov eax, a
cmp eax,200
jne End
Label2 : mov b, 200
ret
Label3: mov a,200
ret
End : mov b,300
}
printf("%d %d", a, b);
}
Give the output of the following code snippet :
void func(char **a)
{
char *str=*(a+4);
int i=0;
char ch=*str;
printf("%s %c",*(a+4),ch);
}
void main()
{
char *str[15]= {"This","is","a","Hello","World","Program"};
char *x;
x=str[4];
str[4]=str[5];
str[5]=x;
func(str);
}
Give the output of the following code snippet : 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);
}
Give the output of the following code snippet :
int main()
{
int a = 10;
int b = 10;
if (a == (a|b))
printf("True ");
else
printf("False");
}
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[j]);
}
Give the output of the following code snippet :
int f(int i)
{
int sum=0;
_asm
{
mov dword ptr [sum],14h
mov eax,dword ptr [i]
add eax,0Ah
mov dword ptr [i],eax
imul ecx,dword ptr [sum],0Ah
mov dword ptr [sum],ecx
mov eax,dword ptr [i]
}
}
void main()
{
int a;
int(*fptr)(int) = f;
_asm
{
push 64h
call dword ptr [fptr]
add esp,4
mov dword ptr [a],eax
}
printf("%d", a);
}
Give the output of the following code snippet :
int mult(int x, int y)
{
_asm
{
mov eax,dword ptr [x]
mul dword ptr [y]
}
}
void main()
{
int(*fptr)(int a, int b);
int a = 0;
fptr=mult;
_asm
{
push 64h
push 4h
call dword ptr [fptr]
add esp,8
mov dword ptr [a],eax
}
printf("%d", a);
}
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 func(int *p,int count)
{
for(int i=0; i< count; i++)
printf("%d ", p[i]);
}
int main()
{
int arry[5]= {1,2,3,4,5};
func(arry,5);
}
Give the output of the following code snippet :
#define offset(type,mem)(int)&(((type*)0)->mem)
int main()
{
struct u
{
char x;
int y;
float z;
} p;
int offx,offy,offz;
offx=offset(struct u,x);
printf("%d ", offx);
offy=offset(struct u,y);
printf("%d ", offy);
offz=offset(struct u,z);
printf("%d ", offz);
}
Give the output of the following code snippet :
void print(int num,...)
{
int i,k;
float j;
va_list marker;
va_start(marker,num);
j=va_arg(marker,double);
printf("%.2f ",j);
va_end(marker);
}
int main(int argc, char *argv[])
{
print(10,2.2,3.3,4.4);
}
Consider the given statement from the below lines of code: What does it indicate?
root->prev=NULL;
struct node *root;
root = (struct node *) malloc( sizeof(struct node) );
root->next = NULL;
root->x = 5;
root->prev=NULL;
Head=root;
Give the output of the following code snippet :
struct student
{
char c[10];
int age;
};
void main()
{
struct student s= {"Jenn",15};
struct student m;
m=s;
char *rev=strrev(m.c);
printf("%s",rev);
}
Give the output of the following code snippet :
void main()
{
char s1[]="Hello \0World";
char *s2;
int len=sizeof(s1);
s2=(char*)malloc(len);
memmove(s2,s1,len);
puts(s2);
}
Give the output of the following code snippet :
int main()
{
int arry[5]= {20,10,5,0};
arry[5]=10;
arry[6]=++(*arry);
printf("%d %d",&arry,sizeof(arry));
}
Give the output of the following code snippet :
int main()
{
int *ary = {1, 2, 3, 4};
printf("%d\n", *ary+2);
}
Give the output of the following code snippet :
int main()
{
enum state {working, failed};
enum result {failed, passed};
printf("%d",failed);
}
Which of the following are valid pointer operations in C?
< NIL>
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 _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b =0, c=0,d=0;
__asm
{
push 10
push 20
mov ebx,30
mov eax, 40
mov ecx,60
push 50
push 70
push 80
call label1
add eax,ebx
mov a,eax
mov b,ebx
add esp, 20
jmp Label2
label1:
mov eax, dword ptr[esp + 8]
mov a, eax
add a, ebx
mov eax, dword ptr[esp + 12]
mov b, eax
mov eax, dword ptr[esp + 20]
xor edx,ecx
mov c,eax
sub edx,ecx
add edx,10
mov d,edx
ret
}
Label2:
printf("%d %d %d %d", a, b, c, d);
}
Give the output of the following code snippet :
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 :
union
{
int x;
char y;
}*p,q;
int main()
{
p=&q;
q.y=80;
printf("%c",p->y);
}
Give the output of the following code snippet :
void main()
{
int a=50,c=10,b=40;
_asm
{
mov eax,35
mov ebx,a
sub eax,dword ptr[b]
jae Label2
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp eax,ecx
je Label1
sub eax,dword ptr[b]
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
int main()
{
int a = 10, b = 20,c=5;
_asm
{
mov eax,a
mov ebx,b
or ebx,c
mov ecx,eax
and ecx,ebx
mov c,ecx
}
printf("%d",c);
}
Give the output of the following code snippet :
int main()
{
int a = 20, b = 10,c=2;
_asm
{
mov eax,dword ptr[a]
mov ebx,dword ptr[b]
shr ecx,2
mov dword ptr[a],ecx
}
printf("%d",a);
}
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
dec ebx
mov a,ebx
}
printf("%d",a);
}
Give the output of the following code snippet :
#define row 2
#define col 2
void main()
{
int (*arr)[col];
arr=(int (*)[col])malloc(sizeof(row*sizeof(*arr)));
for(int i=0; i< row; i++)
for(int j=0; i< col; i++)
arr[i][j]=i+j;
for(int i=0; i< col+row-1; i++)
printf("%d ",*arr[i]);
}
Give the output of the following code snippet :
void main()
{
int i = 0, a = 10;
_asm
{
Label2: cmp dword ptr[i], 1
jne Label1
mov eax, dword ptr[a]
add eax, 1
mov dword ptr[a], eax
Label1 : mov ecx, dword ptr[i]
add ecx, 1
mov dword ptr[i], ecx
cmp dword ptr[i], 3
jne Label2
}
printf("%d", a);
}
Give the output of the following code snippet :
struct p
{
int x;
char c;
};
int main()
{
struct p p1[2];
struct p *ptr1 = p1;
ptr1->c='H';
printf("%d",ptr1->c);
}
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()
{
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,st.t1.c,st.t1.d);
getch();
}
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,dword ptr[c]
jnae 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 :
char *func()
{
char str[20];
strcpy(str,"Hello World");
return str;
}
void main()
{
char s[20];
s=func();
printf("%s",s);
}
Give the output of the following code snippet :
int mult(int x, int y, int z)
{
_asm
{
mov eax,dword ptr [x]
mul dword ptr [y]
sub eax,dword ptr[z]
}
}
void main()
{
int(*fptr)(int a, int b, int c);
int a = 0;
fptr=mult;
_asm
{
push 12h
push 4h
push 10h
call dword ptr [fptr]
add esp,12
mov dword ptr [a],eax
}
printf("%d", a);
}
Give the output of the following code snippet :
int main()
{
int a[4] = {1, 2, 3, 4},n=0;
int *p = &a[1];
int *ptr = &a[2];
n = ptr - p;
printf("%d\n", n);
}
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 );
}
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 :
void main()
{
int a=0x10,b=20,c=30,d;
int x,y,z;
x=a & b;
y=a | b;
z=x | y & c;
printf("%d %d %d",x,y,z);
}
Give the output of the following code snippet :
void main()
{
char *s= "Hello";
char *p = s;
printf("%c %c", p[0], s[1]);
}
Give the output of the following code snippet :
void main()
{
int a[10][10];
int b=sizeof(*a);
printf("%d",b);
}
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 :
struct stud
{
int no;
int no2;
struct emp *link;
};
struct emp
{
int id;
struct emp *link2;
};
typedef struct stud *ptr;
typedef struct emp *qtr;
void main()
{
ptr s=(stud *)malloc(sizeof(struct stud));
s->no=10;
printf("%d",s->no);
}
Give the output of the following code snippet :
void main()
{
int a=30,c=50,b=40;
_asm
{
mov eax,30
mov ebx,dword ptr[c]
cmp eax,ebx
jnge Label2
shl eax,1
xor eax,dword ptr[a]
mov b,eax
Label2:
mov ecx,dword ptr[a]
sub ecx,ebx
jz Label1
and eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
Give the output of the following code snippet :
int sum(int first,...)
{
int sum=0, count=0,i=first;
va_list marker;
va_start(marker,first);
while(i!=0)
{
sum+=i;
count++;
i=va_arg(marker,int);
}
va_end(marker);
return sum;
}
int main(int argc, char *argv[])
{
printf("%d",sum(2,3,4,5,6,0));
}
Give the output of the following code snippet :
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 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(i>0)
{
printf("%c",argv[1][i]++);
i--;
}
}
Give the output of the following code snippet :
int main()
{
int arry[][]= {1,2,3,4,5,6};
printf("%d",**arry+3);
}
Give the output of the following code snippet :
void func(struct stud *stuobj);
struct stud
{
int no;
char name[3];
stud *link;
};
void main()
{
char nameval[]="Penny";
struct stud *ptr=(stud *)malloc(sizeof(stud));
ptr->name=(char *)malloc(sizeof(strlen(nameval)+1));
strcpy(ptr->name,nameval);
func(ptr);
}
void func(struct stud *stuobj)
{
struct stud *s;
s=stuobj;
printf("%s",s->name);
}
Give the output of the following code snippet :
int main()
{
int a = 0;
int b = 0;
int c = 0;
_asm
{
mov eax, 10
push eax
push 100
mov ebx, dword ptr[esp]
mov a, ebx
mov ebx, dword ptr[esp+4]
mov b, ebx
push 300
mov ebx, dword ptr[esp+8]
mov c, ebx
add esp, 0x10
}
printf( "%d %d %d",a,b,c);
}
Give the output of the following code snippet :
typedef struct test *q;
struct test
{
int x;
char y;
q *ptr;
};
int main()
{
struct test p = {10, 20, &p};
printf("%d\n", p.ptr->x);
}
Give the output of the following code snippet :
int main()
{
int a = 0;
int b = 1;
int c = a >> 3;
int d = b >> 4;
if(c == d)
printf("True");
else
printf("False");
}
Give the output of the following code snippet :
void main()
{
int a=10,b=20,c=30;
unsigned int d=2;
int x=10,y=20,z=30;
x=a | b >> c || d;
y >>= 3;
z = y>> 2;
printf("%d %d %d",x,y,z);
}
Give the output of the following code snippet :
int main()
{
const int y=100;
const int* z=&y;
y+=1;
printf("%d",*z);
}
Give the output of the following code snippet :
void main()
{
char x,y;
printf("%d ",(100*-1));
}
Give the output of the following code snippet :
void *func()
{
void *ptr;
int x=100;
ptr=&x;
return ptr;
}
void main()
{
void *(*f)();
f=func;
printf("%d",*f());
}
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()
{
int i, *j, k;
_asm
{
mov dword ptr[i], 0Ah
lea eax, [i]
mov dword ptr[j], eax
mov ecx, dword ptr[j]
mov edx, dword ptr[i]
imul edx, dword ptr[ecx]
mov eax, dword ptr[j]
imul edx, dword ptr[eax]
mov dword ptr[k], edx
}
printf("%d\n", k);
return 0;
}
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 :
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 :
struct node
{
char* data;
struct node *next;
}*head=0;
void addtoLoc( int n,char* num )
{
struct node *temp2,*temp;
temp2=head;
if(temp2==NULL)
{
printf("Empty List");
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;
}
void display(struct node *r)
{
r=head;
while(r!=NULL)
{
printf("%s ",r->data);
r=r->next;
}
}
void add( char* 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("Hello");
add("World");
addtoLoc(0,"Prog");
display(n);
}
Give the output of the following code snippet :
int main ()
{
char *ptr="Hello";
printf("%s",ptr);
}
Give the output of the following code snippet :
int main()
{
int a = 10;
int b = 10;
if (a == (a&b))
printf("True ");
else
printf("False");
}
Give the output of the following code snippet :
int main()
{
char *MemAlloc;
MemAlloc = (char*)calloc(20,sizeof(char) );
strcpy( MemAlloc,"Hello");
printf("%s",MemAlloc+3);
}
Consider the given lines of code : What does the line below signify?
if(head == NULL)
void add( int num )
{
struct node *temp;
if (head== NULL)
{
head=temp;
head->next=NULL;
}
temp=(struct node *)malloc(sizeof(struct node));
temp->data=num;
temp->next=head;
head=temp;
}
Give the output of the following code snippet :
void main()
{
int a=40,c=50,b=30;
_asm
{
mov eax,50
mov ebx,b
cmp eax,dword ptr[c]
jg Label2
mov edx,dword ptr[b]
and edx,eax
mov b,edx
Label2:
mov ecx,dword ptr[a]
cmp ecx,ebx
jne Label1
add eax,ecx
or eax,edx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
What do the following lines of code indicate?
if(temp==head)
{
head=temp->next;
free(temp);
}
int Delete(int num)
{
struct node *temp, *prev;
temp=head;
while(temp!=NULL)
{
if(temp->data==num)
{
if(temp==head)
{
head=temp->next;
free(temp);
return 1;
}
else
{
prev->next=temp->next;
free(temp);
return 1;
}
}
else
{
prev=temp;
temp= temp->next;
}
}
return 0;
}
Give the output of the following code snippet :
int _tmain(int argc, _TCHAR* argv[])
{
int a = 0, b =0, c=0,d=0;
__asm
{
push 10
push 20
mov ebx,30
mov eax, 40
mov ecx,60
push 50
push 70
push 80
call label1
add eax,ebx
mov a,eax
mov b,ebx
add esp, 20
jmp Label2
label1:
mov eax, dword ptr[esp + 4]
mov a, eax
add a, ebx
mov eax, dword ptr[esp + 8]
mov b, eax
mov eax, dword ptr[esp + 12]
xor edx,ecx
mov c,eax
sub edx,ecx
add edx,10
mov d,edx
ret
}
Label2:
printf("%d %d %d %d", a, b, c, d);
}
Give the output of the following code snippet :
int main()
{
int a=10, b=20,*ptr,*qtr;
ptr=&a;
qtr=&b;
*ptr=b+++--a;
*qtr=*ptr+a++;
printf("%d %d %d", a,*ptr,*qtr);
return 0;
}
Give the output of the following code snippet :
void main()
{
int a=10,c=20,b=20;
_asm
{
mov eax,40
mov ebx,dword ptr[c]
sub eax,ebx
jng Label2
mov edx,b
and eax,edx
mov b,eax
Label2:
mov ecx,dword ptr[a]
cmp ecx,ebx
jne Label1
or eax,ecx
mov c,eax
}
Label1: printf("%d %d",b,c);
}
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;
/* Test2.h */
static int value;
void func(int);
/* Test1.c */
#include"Test2.h"
void func1(int);
void func(int arg)
{
value = 200;
func1(arg);
printf("Output = %d\n",arg+value);
}
/* Test2.c */
#include"Test2.h"
void func1(int arg)
{
value = 100;
printf ( "Output = %d\n", arg+value );
}
/* Test3.c */
#include "Test1.h"
#include "Test2.h"
int arg =20;
void main ()
{
func(arg);
}
Give the output of the following code snippet :
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 :
void main()
{
unsigned int a=10;
unsigned int b=17;
int c = a ^ 2;
int d = ~b;
printf("%d %d",c,d);
}
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;
Cobj.Id=1001;
printf("%d",Cobj.Id);
}
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 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 :
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 :
struct Vehicle
{
int Id;
char *name;
struct Car
{
int Id;
char *name;
} Cobj;
};
void main()
{
struct Vehicle Vobj[5];
Vobj[0].Cobj.Id=1001;
printf("%d",Vobj[1].Cobj.Id);
}
Give the output of the following code snippet :
void main()
{
int arry[10]= {1,2,3,4};
printf("%p",arry);
}