7) Provide the syntax to declare an integer array with a constant size of 50 ele
ID: 3904955 • Letter: 7
Question
7) Provide the syntax to declare an integer array with a constant size of 50 elements, then initialize all clements to 1.(5 pts.) 8) What will be the output of the following code? (5 pts.) int num1-1 int num2-5 while(numlcnum2) Console.writetine("(e) is less than (1) num1, num2) nuni 9) What will be the output for the following code? (5 pts.) int numl-5 int num2-1; while(nun1>num2) Console.writeLine("? numl++ is greater than {1)", nual, nun2); 10) The main purpose of Accessors (get/set) is to? (5 pts.)Explanation / Answer
7. Syntax
// declaring an array of 50 elements
int[] a = new int[50];
// initializing all to 1
for (int i=0; i<a.Length; i++)
{
a[i] = 1;
}
8. Output
Explanation
Looping as long as num1 is less than num2
So, it runs for values of 1, 2, 3, 4
9.Output
... and goes on for infinite times because num1 will never be less than 1
10. When a variable with property PRIVATE is used, it can't be accessed from outside of that particular class.
getter: It is used to get the value of the variable
setter: It is used to set the value of the variable
Note: Only 4 sub-parts are answered as part of a question -- Policy of Chegg
7. Syntax
// declaring an array of 50 elements
int[] a = new int[50];
// initializing all to 1
for (int i=0; i<a.Length; i++)
{
a[i] = 1;
}
8. Output
1 is less than 5 2 is less than 5 3 is less than 5 4 is less than 5
Explanation
Looping as long as num1 is less than num2
So, it runs for values of 1, 2, 3, 4
9.Output
5 is greater than 1 6 is greater than 1 7 is greater than 1 8 is greater than 1 9 is greater than 1 10 is greater than 1 11 is greater than 1
... and goes on for infinite times because num1 will never be less than 1
10. When a variable with property PRIVATE is used, it can't be accessed from outside of that particular class.
getter: It is used to get the value of the variable
setter: It is used to set the value of the variable
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.