Assignment Solution 7 Jan 2020
Assignment Solution 7 Jan 2020
2. For an array A[100][100], let us assume that the main memory is byte-
addressable and that the array is stored starting from memory address 0.
So the address of a[40][50] is
a) 4040
b) 4050
c) 5040
d) 5050
= 4050
Note, in case of n1, the null character at the end of the string is also counted.
Therefore, it becomes 18. Whereas, for n2 its not, hence n2=17.
4. Which of the following is a disadvantage of linear search?
a) Requires more space
b) Greater time complexities compared to other searching algorithms
c) Not easy to understand
d) All of the mentioned
Solution: (b)
#include<stdio.h>
#include<string.h>
int main()
{
char str1[20] = "hello", str2[20] = " world";
printf("%s", strcpy(str2, strcat(str1, str2)));
return 0;
}
a) hello
b) world
c) world hello
d) hello world
a) (i%3) == 0
b) (i%2) == 0
c) (s[i]%3) == 0
d) (s[i]%2) == 0
Solution: (b)
Note, to make "How is your exam" to “Hwi orea” we need to take all the
even position element of the string which can be done if we do the (i%2) == 0
condition checking inside the if statement.
a) 0
b) 1
c) -1
d) None
Solution: (a) 0
WEEK 7 ASSIGNMENT SOLUTION
As y is declared as int inside the function fu(), the ASCII value of ‘C’ is passed
to the function which is 67. Hence, 67,67 will be printed.
Solution: 7
A static variable inside a function keeps its value between invocations. Step
numbers represents the function calls.