Beruflich Dokumente
Kultur Dokumente
7 . struct test{ 8.
float a; a) What is the subtle difference
int b,c;}; between malloc and calloc
Write a C program to find the size of fuctions ?
the structure ‘test’ defined above
without using sizeof operator. b) Raju and Veena had a
conversation .
Raju : I allocated memory dynamically
but the beauty is that without using
any pointers.
Veena : Are you joking ? It is
impossible .
What is wrong with that
conversation ?
9. int main(void) 10. union XYZ
{ { int _; char __; float ___; }
int data=014,shift=0x0; X;
while(data>>=shift){ int main(void) {
printf(“%d X._=65;
%d”,data,shift); printf(“%c %d”, X.__, X._);
-+-shift++ + 0x0080; }
}
return 0;
}
15. struct CCC{ int a;int b; } 16. What is the difference between
If I declare int (*p)(struct CCC 1. char **p;
*); then 2. char *p[]; those
What does it mean ? declarations.
17. Write an algorithm to turn on the 18. There are ‘n’ numbers stored in an
desired bit array every number has its own pair
of a given unsigned number ‘n’. except only one number. Find out that
Eg 1 : input : 13 , 2 // 13= number and analyse time complexity.
(1101) base 2 . Eg :4 4 5 6 5 7 6 5 5 5 can be grouped
output : 15 ( 2nd bit from right is as (4,4) (5,5),(5,5),(6,6) but 7 has no
turned on ) . pair so output is : 7
Eg 2: input : 4 ,4 // 4=(100) base 2.
output : 12 // 1100 4th bit
turned on.
19. Correct the following code to print 20. unsigned function(unsigned
the binary pattern of given number num,int n)
and number of bits needed from {
right . while(n--){
void print_binary(unsigned if(num&0x8000)
num,int n){ num=(num<<01)|
if(n!=0) 0x0001)
{ else num<<=1;
((1<<(n-1))&&num)? }
printf(“1”):printf(“0”); return num;
print_binary(num,n++); }
} Give any random values as inputs and
} eg : input 5 , 4 output : 0101 find out what the function does .