Computer Applications
If int a[] = {7, 3, 4, 8, 9, 2}; what are the values of x and y?
(a) x = a[1] * a[0] + a[3]
(b) y = a.length
Java Arrays
7 Likes
Answer
(a) Since array index begin from 0, the given expression is evaluated as follows:
x = a[1] * a[0] + a[3]
⟹ x = 3 * 7 + 8
⟹ x = 29
(b) length of an array is the number of elements in an array. Thus, y = 6.
Answered By
4 Likes
Related Questions
Give the prototype of a function search, which receives a sentence sentc and a word wrd and returns 1 or 0.
How many times will the following loop execute?
int x = 2, y = 50; do { ++x; y -= x++; } while (x <= 10); return y;Write the return types of the following library functions:
(a)
isLetterOrDigit(char)(b)
replace(char, char)Define a class to accept a number and check whether the number is Neon or not. A number is said to be Neon if sum of the digits of the square of the number is equal to the number itself.
E.g.
Input: 9Output:
9 * 9 = 81, 8 + 1 = 9
9 is Neon number.