21
SET- 2 1. (a) Explain the working of unary operator with example. (b) Explain the working of binary operator with example. (c) Explain the working of assignment operator with example. (d) Explain the working of ternary operator with example. Ans: (a) C supports a rich set of operators, such as +,-,=,*,& and <. 1. An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations. 2. Operators are used in programs to manipulate data and variables. They usually form a part of the mathematical or logical expressions. 3. C operators can be classified into a number of categories. They include: 1. arithmetic operators. 2. relational operators. 3. logical operators 4. assignment operators 5. increment or decrement operators. 6. conditional operators 7. bitwise operators 8. special operators. C provides all the basic arithmetic operators. These operators are +, -, * and /. All work the same way as they do in other languages. They can operate on any built-in data type al- lowed in c. Unary Operators Unary operators include 1. addition or unary plus 2. subtraction or unary minus 3. increment operator (++) 4. decrement operator (--) 5. address operator 6. size operator The following table summarizes these operators. C Programming and Data Structures May/June 2008

Solved Question Paper 2

Embed Size (px)

DESCRIPTION

SET-2 Unary operators include 1. addition or unary plus 2. subtraction or unary minus 3. increment operator (++) 4. decrement operator (--) 5. address operator 6. size operator The following table summarizes these operators. Unary Operators

Citation preview

Page 1: Solved Question Paper 2

�����

�� ��� ������ ������������������������ ���� ���������

��� ������ ������������������������ ���� ���������

��� ������ ��������������������� ������ ���� ���������

��� ������ ������������� ������������ ���� ���������

��������������������� ����������������� ���������������������

�� ����������������� �������� ������ ������������� ��������������� � �� !� �

������ ������

"� #�������������������!������������ �������������$���� ����%�������� ������������

������������� � �� !� � ��&��������

'� �������� ������ ����������������������� ���!�����%������ ���(

�� �������� �������

"� � ����� �������

'� !� � ������

)� ����!�����������

*� �� ��������� ������������

+� ������� ������

,� ���-���������

.� ��� �� �������

���$����� � � �������� � �������� � �������%����������� ������ ��� �� ���� /��� �-0

���������-�������������������� ��!��!����%���� ������������������ ���������������� �

-������ �

�������������

1������������ ���

�� ��������������� ��

"� ����� ���������������

'� �� ���������������

)� �� ���������������

*� �����������

+� ��2������

%���� -��!���� ��������2���������������

����� ����������������������������������

Page 2: Solved Question Paper 2

������������ ������ ����

#���� ��� �������� ���

� � ��

3 �����

�� �� �����

�� �� �����

� �����������

4�2��� !�$���������2��������

%���� -��!�������������-0��!���$���������������(

� ������������������

%����������������������������� !���� ��������-��������

������� �����

5������6�������

%����������"7������6�����

8������������������

���������������

��������

/��-�������!����� � � ���������������-���������/

#include<stdio.h>#include<conio.h>

Main () { Int a,b,s; Clrscr(); Printf("enter the values of a,b:");Scanf("%d%d",&a,&b);S=a+b;Printf("%d=sum",s);Getch();}

#�����(����������$� ���������

��������������������������������������������6���

���������������������������������������4����"7�

����������������

%����������������������� ���� ���!���������� !���� ���!������$� ���

�������

�������������������5���&����*79

�������������������5��������&9

%��������!�������$� ������*7�������������$� �����*7��������!�����%���������!���������������-�����

� ��������������� ����������0���� �����������

Page 3: Solved Question Paper 2

���� ������������ ������

��������

/��-�������!���������� ���-���������/

#include<stdio.h>#include<conio.h>

Main () {

Int a,b,s; Clrscr(); Printf("enter the values of a,b:");Scanf("%d%d",&a,&b);S=a-b;Printf("%d=subtraction",s);Getch();}

#�����(����������$� ���������

�����������������������������������������������6

���������������������������������������4���� ����"�

���������������������

%�������������������������������-��������������������� �������������������

�������

:�&��� ������-���������&��

����������2�&����

��;����&�"7�����7

5��������$���&��� ������� �����$� �������������������� �����������������!���������

���������$� ������������ ��������

<��� �����2���"7��7�"77

=-� �������&�"7�����7

�������>�&����

8�������������$� ������������ ��������������������������������� ��

<��� �������2�"7����""7�

�������� ���!�"#"�������

%�����2��������!�$������������� �����������$���� ���%����������������� ������$����

���$���� ����$���� ��

%���?�@�����������������������������$���� ��������������

%����!����� -��&� �����������������

#include<stdio.h>#include<conio.h>

Page 4: Solved Question Paper 2

������������ ������ ����

Main () { Int x=2;

Float y=2; Printf("sizeof (x)=%d bytes", size of(x)); Printf("sizeof (y)=%f bytes",size of(y)); Printf("\n address of x=%u and y=%u",&x,%y);}

#�����(

Size of(x)= 2 Size of(y)= 4 Address of x = 4066 and y=25096.

��� 4��� �������������(

A&������(

A&����������&������

A&����������&������

A&����������&������

A&�������/��&������

A&�������B��&������

A&�����������&������

A&�������C���&������

A&����������&������

A&�������D��&������

A&�����������&������

A&�������D���&������

A&�����������&������

A&�������EE��&������

A&����������&������

A&�������/��&������

A&�������F��&������

A&�����������&������

A&�������DD��&������

�������������'����������������'

��� $���%�����������

����!��������������������������!��������� ��������&�����������$���� ���;����$����������

���� �����!�����������G�G�

5��������������������������G�������G�����!��������������������

H�����&�9

�;����GHG������$���� ���G�&�G��������&�����������?�@������?�@��������������� ������

%��������������0�-���������������������!�����������

%�������!���������������

H������&�9

Page 5: Solved Question Paper 2

���� ������������ ������

�������

:�����9

%������������������������������&�&������9

4���������-�������� ������!���������� ����������-����������������

����� ����

����� ����

��������� ������

���/����� �/����

���B� �B��

%���������������������!�����������������������$����!��(

�� ;����������������� ����������������������������������%������������ ������������-����

"� %������������������� � �������������������

'� %����������������������� �����

��� %������������������ �� � ������ ������� ������

4����&(

A&��I�&�"(�&�'9

;�����&�����&�"������&�'�����&��������

��������� �&������'��!��������������

%���$� ������&��� ����$� ������ ������ 5�� ��� ��� �����$� ������&�"� ����$� ����������-�����&�'� ��

�$� ������

�������

��������������

�����������

5��������$������������������&��������D������$� �������4�� ���������� ����$� ����� �-� ��������!���

����

4������$� �������-� �����*�

�����������������������J������I�( 9

8����������������$� ��������������!����������

4��$� �������-� �����77�

��������

���������������������������� ��!����"������ �������#���#���"�#"����������$������������

#include<stdio.h>#include<conio.h>

Main () {

Int a,b,c,largest; Clrscr(); Printf("enter the values of a,b,c:\n"); Scanf("%d%d%d",&a,&b,&c);

Page 6: Solved Question Paper 2

������������ ������ ���

Largest=(a>b)?(a>c)?(b<c)? a:b:c; Printf("the largest number is: %d", largest); Getch();

}

� !�� ��� �����"�� ���������������� �����!� ����#$%��������� ������������� ��� &�

���� ����� ������������

����� ����� ����������� �� ���������!�����!������������������� ��� �����-� ������������0��

1�������� �������������� �� �&����0�������$����!������!���������� ���

%��������-���� ��������?�@� ��!��!�

�� �!���������������� �����

"� �������� �����

�$!(���%��� �����%� ��������

�� ;�����!�������$��� ��!��������� ��!�������� ��������� � ���5������ ������� � ��������!

���������������� �� ��!�����!�����5�������$� �����������-�� 0��� �� �&���

!���� �����������$������������ ����� ����%�������� ��������� ������������!���� �

������8�� ������������!�������� �������0���!��������������������������!����

�����

"� %����������!���-�� ��������������������������������������� ������-�������������� �

�������� ������ � ���-���$������������$�������������%������ ��������� ��!�������2���

�����!���

'� ����� ���� ���������������������!����

)� 5���� � ����������-����� ���!�����!�

K����-����!����!�������� �������� ������ ������0�-�-������������������� �������� �����

K�� �������� ����

�� K�� �������� �������� ��� ���L�������� ����������������!������!����������������

����� �����

"� %�������� ������������������ ��

'� %�����������-��������������!������

)� ;�������� �����-���� ���� ��� ������������������������� �� ����� �!���� ��� ��������� ����

��� �����

*� %�����������������

+� K�� �������� ����� ��������$� �����

,� M!������$������������ ��������������������$�� �� �����?����������@���� �����

.� � ������$�� �� ���������!�������� � �

6� %�������������������������������� �������

�7� N� ���������������� �������� ������������L����

��� A&��� �(� ��&����L��&�������&����� ��

%���� -��!���������!������&� ������������ �������� �����

��������

/����?�@��!���������������L��������&��/

Page 7: Solved Question Paper 2

���! ������������ ������

#include<stdio.h>#include<conio.h>#include<math.h>

Void square(int); Main () { Int x,y;

Printf("enter the value of x"); Scanf("%d",&x); Square(x); Y=sqrt(x); /* call to a built-in function */ Printf("%d",y); } Void square(int a) { Int p; P=a*a; Printf("%d",p); }

%������ �������� �����L��&������$�� �� ����������������� ������������� ��O������O����� ����

���������� �������������!���

'� !�� ��� �����"�� ������������������(�)"�� ������ ������������� ��*�������������

��� ������&���������������

����

������������ � ��$�������!�$�������!��������� ��� �������-��������$���� ��������

���������������� ���!������!��!����&� �����

%���� -��!����������$����!���������!������

�� ������������$���� ����������� ���� �������� ��!������$� �����-���������������

$���� �� ���� �������! ��$� ��������������P��&��� ���������������� �2�����-� �����

�����������Q.R9

��-�� ������������!������!�� ���������$���-������!������������$� ���� �����

������� �!��!���������������������������$���� �������� �2�����-� �����

���������9

����� ��������!�� �����������$������� ���� ��� �����$� �������������

"� A ���������������� ������������ �2�������������������� � ����������� ������

��������������-��������� �������

5�����Q)R����S*�+�,�.T9

5��������$���&��� ������� ����������������������������%�������� �����������������

���!��������� �������%�������� �����������������?7@��������Q7R��������!��������$� ��

?*@��4��� � ����Q�R��������!��������$� ���+��%���������)�����Q)R������������������ ��������

� �������

Page 8: Solved Question Paper 2

������������ ������ ���"

%��� ������������������������������������������ ������ �����������������������������������

����������%������������� ��������

%������������������$����!���������!�������%���� -��!������������������&����� ������

� �����!�����������!������������� �����

���)!����������$����

5������������� �������������������-�� ������ ������� ������������������ ���!��������

����������� ����������!�� ��������� ����

�������

5����� Q�7R9

8����� ��������������7�����!���

�*���������� ���)!����������������

%���!���� ���������� ���!������������ -�(�����%�������U�����Q��2�R9

-��������%���������������������������� �����������U�������������������$���� ��������2�

��� ������ ������������� ������� ��� ���������%�����2�������� ��� ��&������ ��� �� ��������� ��

�������� ���!�������!��&� ��������!���

�������

���������������������5�����Q*7R9

���������������8���������� ���� ��*7�����!���

%������ ���2������������"�*7��77�����@���%��������� ������� ������!��� �������L�����"������

�����!��

�����������%����!��������%�

;�� ��������� �2������� ��������������� � ����������� ���������� ���%���!���� ������������

������ �2��������

%�������U�����Q��2�R�S ������� ������������������� ����T

�������

�������������������5����Q)R�S*��7���**T9

8���������2����������������)��*��������!������������ ��������������Q7R�*��7�������

��!�������� ���� �������������Q�R��7�����������!������������ ��������������Q"R����**��������!�����

������ �������Q'R�**�

4���������� ������� ����������� ��������� ���������������2�������������� ������������� ������

��������� �2����%����������!�� ��������������!����!���!��$� ����

�������

�������������������5���&�2Q*R�S�7�*�"7T9

8�������������� �������������!����$� ����7���� ���� �������������!����$� ���*����������� �����

�������!����$� ���"7��4�� ������� ������� ���������� ���������������2������������������������!��-

� ��������������!����!���!��$� �����5���&����!���� ��������7�����������������������Q�R��-�

��$��$� ��������Q7R��Q�R�V���Q���R�

�������:�2Q7R��&�2Q�R�*��&�2Q"R�"7�

Page 9: Solved Question Paper 2

���# ������������ ������

�������:�2Q'R��������!����!���!��$� ���

�������:�2Q)R��������!����!���!��$� ���

������������ -��!����������

��������5����&�2Q�R���Q*�+�,�.�6R9

5��������$�������������-������������ ����������2�������������5���� �� ������ ��� ����&������

��2������������������������$� ����������� �����5��������$���������������� ��-����$����$��$� ���

������� �������2���������������*�

5��-��-���� �� ������ �2��� ����������� �!����2�������� ����������"*7�� ��������� ����� ��� ��

����� � ���������� ������ ������������������������� �������5���� �� �������� ��������������

�����&� � �� ���5��?�@��-������ ����-�� ��������-�� ����������� ��������� ��������%��������

���� ����������� �2��������������2�������

%���� -��!�������!����������������� �����

/���M!�����-��!������������� ������/

#include<stdio.h>#include<conio.h>

Main ( ) { Int i; Float x[10], value, total;

/*�reading values into array */ �Printf("enter 10 real numbers\n"); ��For(i=0;i<10;i++) { Scanf("%f",&value); X[i]=value; } /* computation of total */ Total = 0.0; For(i=0;i<10;i++) Total= total+x[i]*x[i];/* printing of x[i] values and total */

Printf("\n"); For(i=0;i<10;i++) Printf("x[%2d]=%5.2 f\n", i+1,x[i]); �Printf("\n total =%2f \n", total); }#���������7��� �������(�������"�"��'�'��)�)��*�*���+�+��,�,��.�.��6�6��7��7�

+� ,������ ��� ���������� �� ��������������� ����������������������������������

����� - ��� ����

;�������-������� ��������� �������!��������������������� ����������� ����������������!

������������������ � ���������� ��������������4��������������-������������������

Page 10: Solved Question Paper 2

������������ ������ ���$

�!����!������������A� ����������-� ���$���������� �������������� �����������%���������

��������� ���������������������! �������������������������� ������������������������

������Q��������������!�� �����������������!��������� �����������!R��%����� ���� ������!��

���������$����������$�������������0�-�������� ����

student

name

Roll. no

branch

��������! ��������

����� ��������� � ������������������������������������������������! ��������#������� ������

�� � ����������!�����������������

������������ ��������� �������� -�

4�� ������!�D

���������� { Data type member1; Data type member2; ……….. …………… Data type member n; };

� 5��������� ��������� �������0��-��

� ���!�D�������������!�$������������ ������ ����

� �N��������� ����������!���� ���� �����������������������

� �������������"�V������������������������� ������5���$���� �������

������$���� ������������������������ �����

� 5���$���� �������� �������������� �2���-��������� �������������������

��� ��������������� ����������$���� ���� ���������$���� ������� ������

� -��

4�� �����!D�$���� ���$���� �"VVV$���� ���9

� H���� �����$���� �"�VVV$���� ���������� ����$���� ������������!�

� ����� ���!��� 0������� ��G9G������������� ������

� W����������� ���������� $�������� ����������� ���W�������� ������ �

������� ���!���� ����$���� ���

4�� ���� �������� �������

4�� �����!

�����������S

�����������������%�������������9

�����������������%����"������"9

Page 11: Solved Question Paper 2

���� ������������ ������

�������������������VVVV�

�������������������VVVVV

������������������%�������������9

�������������T��$���� ����$���� �"�VVV��$���� ���9

5������ ��������$���� ���������!���������

�������

����������������4�� �

��������������������S

��������Q"+R9

5����!�9

����!����Q+R9

���� ������Q"*R9

���������������������T�����"9

5��������$���� ��������������������������� ������� ���������

�$������%���+���� ��������

4�� ����������� ������� ���������-����!�$���� ��������������N������������ ��0����� �

����$���� ��������������������5�����������!������� ���� �������������� ����$� ����� �����

�!���

����!���!�$� ��������� ���(

#���-������������!��$� �������������������� �����!���� ����$���� ���

4�� ����������SX�$�Y�X"�Y�X�� �Y�X�������YT

������-������������!��$� �������� ��������������� �������-���� -�

4� �����������X�$�Y�9

M���!��"�9

4� ������!�����X�� �Y�9

4� ������ �������X�������Y�9

8����������&��� ������������!�������� ����-���������� �2���$� ����

/����� ����-���������� �2���$� �����/

#include<stdio.h>#include<conio.h>Void main ( ) { Struct organization {

bb Char name[20]; Char designation[20]; Int sal; };4�� ��!���2����������SX���Y�X�� ����Y�X.777YT9

4�� ��!���2��������"�SX�Z�Y�X����!�Y�X�.777YT9

Page 12: Solved Question Paper 2

������������ ������ ����

M�����X����� ������� ��������B B B�Y���������������������!�������������� �9

M�����X����� ������� ��������B B B�Y����"����������"�����!����������"��� �9

T�

.� !� ������������ ������� ������������ �*� ������ ���"������������ ������������� ��

��� �� ����� ������

/ �� ���� ���� 0��� �

��� �1� 2��� 1 .

���� �1' 2���' �11

����

��������

���������������������� #include<stdio.h> #include<conio.h> Void main( ) { Struct shop { Char itemname[30]; int code; Float price; Int quantity[20] ; };

Struct shop item1={"pen",101,20,5};Struct shop item2={"pencil",103,3,100};

Printf("value of each item1(pen)is=%f",item1.price);

Printf("value of each item2(pencil)is=%f",item2.price);

Printf(display the contents of the file isitem1=%c%d%f%d",item1.itemname,item1.code,item1.price,item1.quantity);

}3� $������� �����"�� ������������"�� �������4����*����� ����������� ������ �

����

4�������� � ������������� � K��� ������ !�����������!� �������� �������� ����� !�

������-�� ��!���2�����������!�� ������������� �� �� 0��!������-���Z� ����� ����������

� ���! ����Z�����!��������������� 5�� ��� ������ ������� ����� ������������ ��������� �� �����

-���������� ����������������� ������������������8�� ����������������� �����������������

����������������������������L�������������K��� ���������������� �������� ���������!��� ��

��L����%������������0����-�� ������������������5�� �������������-�� ��������5�������� ��������

����������� ������������ ���������� ����������������5������������ ���������!������������ ��

������������������-�������%���� ����� ��������-����������&���-�� ����������������-�����

����� ����������������5������������������������ ����������������� ������ !������%�������

���� ������ !��������#��"��

Page 13: Solved Question Paper 2

�� � ������������ ������

��������

�������������������� *���'���������)�����"

������������������"� '���*����������)�����"

������������������'� '���*�����������)�����"

������������������)� '���*�����������)�����"

������������������*� '���*�����������"�����)

��������

/���M!������������� �����������!����� ������� ���L����/

#include<stdio.h>main(){int i,j,t,a[5],n;clrscr();printf("enter the range of array:");scanf("%d",&n);printf("enter elements into array:");

for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n-1;i++)for(j=i+1;j<n;j++)if(a[i]>a[j]){t=a[i];a[i]=a[j];a[j]=t;}printf("the sorted order is:");for(i=0;i<n;i++)

printf("\t%d",a[i]);getch();}

���%��������!��������L���������� ����������������0���������������L�� 0������������

������ �

�����������

5����������������� ����� ����!� �����%�������� ��������������������&�� ���� �������������

�������!� ������������������������&�� ���� ���������� � ��� � ���%������� ��� �����������

������#��"��

��������������!!������������������������ ���L����-�� ������������� ��������������������

�������� �����!��� ��� ������-�������� �������!�� ��������������������� ��������� ��

��! ���$�������������!�$�������

Page 14: Solved Question Paper 2

������������ ������ �� �

�������������������� �������-��������&��� �

������������6��+���)��"���

"�����������+��6���)��"���

'�����������+��6���)��"���

)�����������"��+��6���)���

*��������������"��+��6����)�

���������

/���;���������!����������� ������������������������������/

#include<stdio.h>main(){

int i,j,t,a[10],n,p=0;clrscr();

printf("enter the range of array:");scanf("%d",&n);printf("enter elements into array:");for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=1;i<n;i++){t=a[i];

for(p=i;p>0 && a[p-1]>t;p--)a[p]=a[p-1];a[p]=t;

}

printf("the sorted order is:");for(i=0;i<n;i++)printf("\t%d",a[i]);getch();

}5�����������L�������� �������������L�� 0��������������������� ������

����������

���� � �������� !��������� ���� ��������� � ���!� ���� �!����� ������ ��� ����������� �������

� � ������������������������������5���� ����������� �!����� ������������� �������� � ������������

������������5������������� �������������� ���������

5����������������� ������ ���������� ���������� �!����� ���������� � ���������� �����������

5�������� ������������������� ���������� ����������� ���� ���������� ��������"�� ��

����������������'�� ������������������� ������� ������

5������������� ��������-���L���������������

%�������� �� �&�������� � ����������#��"������� � �����

Page 15: Solved Question Paper 2

�� � ������������ ������

��������

/��;������?�@��!����������� ������������� � ���������������/

#include<stdio.h>#include<conio.h>Void main() { Int a[20],I,j,temp,t,n,max; Clrscr(); Temp=0; Printf("\n enter the no of elements in the list:");Scanf("%d",&n);Printf("\n enter the elements of the list\n");

For(i=0;i<n;i++)Scanf("%d",&a[i]);For(i=n;i>1;i--) { Max=0; For(j=1;j<I;j++) If(a[j]>a[max]) Max=j; Temp=a[i-1]; A[i-1]=a[max]; A[max]=temp; }

Printf("\n elements in the ascending order are as follows:\n");For(i=0;i<n;i++)Printf("%d\n",a[i]);Getch();}

$!(���%�

4� � �������������2���������$���������������!�������������������� ������������$��������

8�� �������� !������������� ��� �������� ������ �!��� �������-�����$�����������������

�&�����$��

*���!(���%�

5������� �������������������!� ��0��� �������������������������������� ������������ � �������

5���L�������� �������������L�� 0��������������������� �����������L�� 0����

�5� ,�������� ��� ��� �� ������������ ������������

���� �������� ��������������N%�������!���� �-�����!����������������������������������

�������� � �� ��!��!���%-�? ���� @��N%�����[��������4�� 0��%����� � ������&�������!����

Page 16: Solved Question Paper 2

������������ ������ ��

�������4 ��� ���4 ������ ���������� ��������� ���������������� ��!��!����%���0������������

�-����������������������������������������������N%���������� ����������� ������$����

��!��!����5��##� ��!��!��� �0��\�$�������N%�-� ������ � �������� ������������� �����!��

�� �������5�����##� ��!��!��� �0��������-� �������� ��������������������� ���������������

��� ���������� � ����!���������

%����&��� ������������� ������������ ��������� �������������� 0��L������ ��0��� ������� ��[�����

��� ������������������ ��

���,�

����� 0� ������������� ���� ���-�� ��������������-�� ��������� �����������&�����!�� �����

� -������0���� � �������������������%����������� � �������������� 0������� 0����!���� ����� ��

�������-�����-����� ����������%��������������������8����������������� -�������!���

� ������������������������� 0�

M���������� -����$� ������� ������������������ ������� 0��K������0��!������

��� 0�������!����������$��������������� �����-���������������� 0��%���������$�� �-�����

���������!������ 0��� ������������!��������������!����������������!� ��0��� ������� �

%���� -��!��!����&� ������������ 0��������!����! �� ��0��� ����

��������

/��;�������!�������� ������������� 0���������������!����! �� ��0��� ����/

#include<malloc.h>#include<stdio.h>struct node{int info;struct node *next;

};

typedef struct node *nodeptr;push(nodeptr);nodeptr pop(nodeptr);

main(){nodeptr stack;int choice;clrscr();stack=NULL;

while(1){printf("\n\t1\tpush\n\t2\tpop\n\t3\tdisplay\n\t4\tEXIT\n");

Page 17: Solved Question Paper 2

�� ! ������������ ������

printf("ENTER YOUR CHOICE");scanf("%d",&choice);

switch(choice){case 1: stack = push(stack);break;

case 2: stack = pop(stack);break;

case 3: display(stack);break;

case 4: exit();}

} getch();}

push(nodeptr stack){nodeptr temp;int info;printf("ENTER THE ELEMENT TO BE PUSHED");scanf("%d",&info);

temp=(nodeptr)malloc(sizeof(nodeptr));temp->info=info;temp->next=stack;stack=temp;return(stack);

display(stack);}

display(nodeptr stack){printf("TOP");while(stack != NULL){

printf("%d",stack->info);stack=stack->next;printf("->");

}printf("NULL\n");

}nodeptr pop(nodeptr stack){

Page 18: Solved Question Paper 2

������������ ������ �� "

nodeptr temp;if(stack == NULL)printf("POP OPERATION IS NOT POSSIBLE");else{temp=stack;printf("THE POPED ITEM IS %d\n",stack->info);printf("press any key to continue");getchar();stack=stack->next;}free(temp);return(stack);}

/*5=M1%�/�#1%M1%

� M148

" M#M

' N54M[�J

) A:5%

A=%A<�J#1<��8#5�A �

A=%A<�%8A�A[AWA=%�%#�KA�M148AN ')

� M148

" M#M

' N54M[�J

) A:5%

A=%A<�J#1<��8#5�A '

%#M�')�D=1[[

� M148

" M#M

' N54M[�J

) A:5%

A=%A<�J#1<��8#5�A "

%8A�M#MAN�5%AW�54�')

M<A44��=J�]AJ�%#��#=%5=1A

� M148

" M#M

' N54M[�J

) A:5%

A=%A<�J#1<��8#5�A )

A:5%�

6� ��� !�� ������� ����(

��� !�� ������������� ����(

Page 19: Solved Question Paper 2

�� # ������������ ������

��� ,������������������ ����

��� !�� ����� ���"������ ��"���������� ����(

����

��� !�� ������� �����(

������ �����-0������� ��� ����/� ����� ��������-�����-��������

������������� ���!���?�@� ��!��!����������-0����������� ��� �������-�����-���������

��� ����� �����������!������������!�����^����������� ��� ����-���������

���� � ��� ��!���%��� � -��!�!���� �&� ����� ���� ��-���-� �������-0�������� ��

�������

��� !�� ������������� ����(

���� 4������!������������� ���������������!������8�� ����������!�������������� ���������

������!�-����� ���������!���-�� ���������� ������� ��� ��� ����������-�����������%���

����-��������� ������������!����!����������!�����

�� A� ���������������������������!��������� ������������! �������

"� %�������������!�����������������!����������� ���������������� ��������������Q����

���� ���������?�@������������������!������ ���������R�

'� 8�� �� ���� ����������!� �� ����� �� ���!�� ��$����������� ����������� �����

����������������!�������8��������-��&��� ������������!������

A

B

C

A

B

C

D

%��������������Z� � �������� ������-������ ���������!������%������

�� N������������� ���������!����

"� K�������������� ���������!����

'� �������������!�����

%����������!���������������� �������!������������������� ���� ���������� � ��������� �

��� ���������������� �����%����������!���������������� �������!�������������������� �

�� ���������� � ��������������������� ���������!�����

;�������������� ������ ������-������ ����!����������������!����������� ������������!����

��������!��������������� ������� �������!����������������!�����

K����������� ��������������������!�������������������� ����� ����� �������$������������

� �������� � �� � � � ������������������!������������������������� 0����������-0��

Page 20: Solved Question Paper 2

������������ ������ �� $

��� ,������������������ ����

����

%������������������!������W4%������-��!�����!����������������!�����-������������!�

-��!������������� ��%������������������!�������� ��������� �����������-0��� ��� ���

����!�$���������$��� ���

]��0� @��� !����������������������!�����-0������������!���!������������� �����!

���������!������!������������������-�� �� ��� ���-���$��� �����Z���� ���������

%������������������!������W4%������!���������������� �������������������!��������0����

����!���� ������ ��� ���� ��������%� ������ �������� ������� � � �� ���������� ��

���������������!��������� ������������������������!���������������������������������-���!

� ���������� ��� �����������������!���� ��� ��-����������� ���5����������������� ����-0

����!���� ����

W��������������!�������$��������������$�� ������(

∑ %���� ������ �������L�� 0 ���������� ������� ����������������!����������� � ����� �

����������!��� �!����

∑ %�����$������-�������������� �����������������������N� ����!����� �!���!�������

���������������!����� ��$��� ��� ���� ������������������������� � ������������

���������

∑ %���� �������������!�$�����&������� �������������� ������ �����4�������������

��$� ��!��� ������

∑ ��������� ����� �� �����������������!������ !�������$����!���� ��$���� ������

!������ !������ ���!�$���$�� ������� �� ������

A&��� �������������������!����

������ ���������) 7����������������� ������������� ���������)

8����9�����%������ ������� ��� ������ ������������ ���� ��� ����

:-7��������

)"����������� ���������);�<*������������� ����&=2>*��������������������� ���

7�

9�����%������ ��

�� -� �;������� ��1;?@

� -��� ��������������������"������ ����&������� �� �7;A�&������?�@�=�������

Page 21: Solved Question Paper 2

�� � ������������ ������

�����������;�&������?�@��/������������������ �*�B� �7;A�=����� ���

'� 2����������>���2� ���� ��- ��� �

7��� �����0��������9�����C������ �����D�E�E��E<E��

��� !�� ����� ���"������ ��"���������� ����(

���� ������

%�����$��� ����������������(

�� 5�������$���

"� M�������$���

'� M��������$���

/�&������ ��"�����

5�������$��� �����!�$������� -��!�������

�� %�$�������� �����������

"� M �������������

'� %�$���������!����������

4������&��������������������������������!�����$�������_K_�_A_P_N_^�

���&������ ��"���� ������

M�������$��� ���������������� -�(

�� M �������������

"� %�$�������� ��������������������

'� %�$���������!�������������������

M�������$��� �������K�����N��A��P��^

��� &������ ��"�����

M��������$��� ���������������� -�(

�� %�$�������� �����������

"� %�$���������!����������

'� M �������������

���� ���������� &������ ��"������

����(� �� 0��������������������$������!���������<�������������������

<�=1[[������������O���������O

�����(���� ������<�C�=1[[������ � ��������� ������<��

�����(�����������<��

���� (�����!�����<�C��=1[[������ � ���������!�����<��

�����(������

A

B

CG

D

E

F

A

B

CG

D

E

F

A

B

CG

D

E

F