11) answer is b) declaring and accessing array
13) answer is 2 15 6 8 10 because change function takes array as pointer and changes *(b+1) = (*b+i) + 5 so second element of array is changed by adding every element in array and adding it 5 to it so the last element is the one whose changes will be present which 10 + 5
14) it is an infinite loop because x = 0 initially and it always decreasing so it will always be less than 0
16) answer is sentinel controlled loop because when user inputs -1 loop breaks
int short real float Question 11 The square brackets [] are commonly used in C for......
Class: C++ Final Exam Dates Multiple Choice Identify the choice thar best completes the statement or answer the question N 1. In s tructures, the computer repeats particular statements a certain number of times depending on some condition(s) a. looping C. selection b. branching d. sequence 2. What is the output of the following CH code? count = 1; num - 25; while (count < 25) numnum - 1: count++; cout << count << " " << num << endl;...
Please write code in C++ class S ( private: int data; public: S0 0; S(int n); void Inc0; void Grow(int n); Problem 3: Given: void Reset(int n); int GetSO:3; S:S (int n) ( data n;) void S: Inc0 (data++) void S::Grow(int n) {data + =n;} void S: Reset(int n) data n;) int S: GetsO f return data; ) Find: int maino t S a(8), b(2); a.Inc0; cout<ca.GetsOendl; I.. b.Grow(4); cout<<b.GetsO<endl; II
Incorrect Question 12 0/4 pts What of the following are true for the following piece of code? int main() int a[ ] = { 2, 4, 6, 8, 10 } int i; change ( a, 5); for (i = 0; i <= 4; i++) printf("\n%d", a[i]); return 0; void change ( int *b, int n) int i; for (i - @;i<n; i++) this line void change(int *b, int n) has an error. We must have to use int b[] as...
Multiple Choice Identify the choice that best completes the statement or answers the que 1. Which of the following is a valid Java identifier? Spay b. 4myGrade! c. newGrade! d. 1dollar static final int EndVal-1: int double; int num console.nextInt(); while (num != Endval) double num * 2; System.out.println (double); num console.next1nt(); 2. The above code is an example of a(n)--while loop. a. flag-controlled b. counter-controlled c. EOF-controlled d. sentinel-controlled 3. The length of the string "first java program" is:...
Step 4: Add code that discards any extra entries at the propmt that asks if you want to enter another score. Notes from professor: For Step 4, add a loop that will validate the response for the prompt question: "Enter another test score? (y/n): " This loop must only accept the single letters of ‘y’ or ‘n’ (upper case is okay). I suggest that you put this loop inside the loop that already determines if the program should collect...
Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...
Given the following class: class Q2 { private int a; private int b; private int c; public void setA(int a){this.a = a; } public void setB(int b){this.b = b;} public void setc(int c){this.c = c;} public int geta(){return a; } public int gets(){return b;} public int getc(){return c;} public int m1(int a, int b){ return a + b; public boolean m2 (int x, int y){ return m1(x, y) + x + y < 10; What is the output of the...
1. Please provide a C++ program which faithfully reads a list of non-negative integer scores, ultimately terminating the list reading when the sentinel value (lets use -9999) is entered. The program should then correctly report the number of non-negative scores entered and the arithmetic mean (average) of those scores 2. Demonstrate your programs behavior in response to errors on input (that is, show that it faithfully rejects improper input such as alphabetic characters, decimal points, and commas). Here are some...
/* I want to fix void make_flight(int counter, flight_t flights[]) Enter flight code> Enter departure info for the flight leaving SYD. Enter month, date, hour and minute separated by spaces> Enter arrival city code> Enter arrival info. Enter month, date, hour and minute separated by spaces> It should do all of this: 1-Flight - left aligned, MAX_FLIGHTCODE_LEN (i.e. 6) chars at most. 2-City - left aligned, MAX_CITYCODE_LEN 3 chars at most . For example( VA1 or LAX ) 3- Month,...
2. What is the output of the following code fragment? n = 1; while (n <= 5) { n++; cout << n << ' '; a.1 2 3 4 5 b. 1 2 3 4 c. 1 1 1 forever d. 2 3 4 5 e. 2 3 4 5 6 3. What is the termination condition for the following While loop? while (beta > 0 && beta < 10) { cout << beta << endl; cin >> beta; }...