Consider the given Cprogram :
main ( )
{
char s [ ] = ( ‘a’, ‘b’, ‘c’, ‘\n’, ‘c’, ‘\0’ };
char *p, *str, *str1;
p =& s[3] ;
str = p;
str1 = s;
printf (“ % d”, ++ *p +++ *str1-32);
}
What should be the output of the above program ?
-
Solution
p is pointed to character‘\n’, str1 is pointing to character‘a’. For ++ *p, p is pointing to ‘\n’ and that is incremented by one. The ASCII value of‘\n’ is 10 which is then incremented by 1 to 11. The value of ++*p is 11. ++* str1,str1 is pointing to a that is incremented by 1 and becomes b.ASCII value of B is 98.
Now performing (11 + 98 – 32) = 77 (“M”) so,
Output = 77.
Which of the following functions is performed by loader?
Consider the grammar:
S → ABCc |Abc
BA → AB
Bb → bb
Ab → ab
Aa → aa
Which of the following sentences can be derived by this grammar?
For two regular languages
L1= (a + b) * a and L2= b(a +b)*,the intersection of L1 and L2 is given by
Regarding power of recognition of languages, which of the following statements is false?
Algorithm which solves the all-pair shortest path problem is
The function
int fun(unsigned int a)
{
if (a==0) return 0;
else return fun (a + 1) ;
}
is a bad recursive function because
-
Solution
The recursive case does not approach the base case for a >0. So, the given function is a bad recursive function.
e.g.,a = 1
Fora = 1, the else condition executes, it will always call the function fun with incremented value of a, again and again.
A full binary tree with n leaves contains
Suppose DATA array contains 1000000 elements. Using the binary search algorithm, one requires only about n comparisons to find the location of an item in the DATA array, then n is
The minimum time delay required between initiation of two successive memory operations is called