Pages

Monday 27 August 2012

CISCO Placement Questions and Answers 2011

CISCO Placement Questions and Answers

1.

char a =0xAA ;
int b ;
b = (int) a ;
b = b >> 4 ;
printf("%x",b);

What is the output of the above program segment ?

a is of 8 byte,a's binary representation = 1010 1010
since MSB is 1 ,it will be considered as -ve number.
say int is of 32 bytes so to get the actual take out a 's 2 complement..

which will be
1111 1111 1111 1111 1111 1111 0101 0101

when you right shift it by 4 it will become 1111 1111 1111 1111 1111 1111 1111 0101
left most side of 1111 will not be 0 because it is a -ve number so sign bit will be extended..
hence o/p will be fffffff5( 64 bit PC)


2. Output?

int main()
{
char *ptr = " Cisco Systems";
*ptr++;
printf("%sn",ptr);
ptr++;
printf("%sn",ptr);
getchar()
return 0;
}

int main()
{
// Initialization
char *ptr = " Cisco Systems";

// Binding *(ptr++) due to right to left associativity
// The pointer incremented by one and then dereferenced
// The r-value is not caught in any l-value expression
// So the result is discarded, yet the pointer incremented
// Now, ptr points one character past the initial base
// i.e. "Cisco Systems" (there is space)
*ptr++;
printf("%s\n",ptr);
// One more increment
// Now ptr pointing "isco Systems"
ptr++;
printf("%s\n", ptr);
return 0;
}
Result:
Cisco Systems
isco Systems

3. what is a super block?

The superblock is an area in a storage device of a Linux computer, which stores various bits of information about a file system, such as a pointer to the free blocks structure, the number of free inodes, etc. In case the superblock is damaged and cannot be read, an error message is generated by the system. In this case, the E2FSCK utility is used to troubleshoot the issue by passing the superblock parameter manually.

No comments: